├── .gitignore
├── .gitmodules
├── .travis.yml
├── JustAnotherVoiceChat.Server.Dummy
├── JustAnotherVoiceChat.Server.Dummy.csproj
├── nlog.config
└── src
│ ├── Client
│ └── DummyClient.cs
│ ├── Factories
│ └── DummyClientFactory.cs
│ ├── Interfaces
│ └── IDummyClientRepository.cs
│ ├── Program.cs
│ └── ServerHandler.cs
├── JustAnotherVoiceChat.Server.GTMP.Resource
├── Client
│ └── JustAnotherVoiceChat.js
├── JustAnotherVoiceChat.Server.GTMP.Resource.csproj
├── JustAnotherVoiceChat.Server.GTMP.Resource.csproj.DotSettings
├── LICENSE.txt
├── Properties
│ └── AssemblyInfo.cs
├── Server
│ ├── Helpers
│ │ ├── RadioHandler.cs
│ │ └── TelephoneHandler.cs
│ ├── VoiceScript.Commands.cs
│ ├── VoiceScript.GtmpEvents.cs
│ ├── VoiceScript.VoiceEvents.cs
│ └── VoiceScript.cs
├── meta.xml
└── packages.config
├── JustAnotherVoiceChat.Server.GTMP
├── JustAnotherVoiceChat.Server.GTMP.csproj
├── JustAnotherVoiceChat.Server.GTMP.nuspec
├── LICENSE.txt
├── Properties
│ └── AssemblyInfo.cs
├── packages.config
└── src
│ ├── Elements
│ ├── Clients
│ │ └── GtmpVoiceClient.cs
│ ├── Server
│ │ ├── GtmpVoiceServer.Events.cs
│ │ ├── GtmpVoiceServer.Players.cs
│ │ └── GtmpVoiceServer.cs
│ └── Tasks
│ │ └── GtmpPositionalTask.cs
│ ├── Exceptions
│ └── ServerNotSharedException.cs
│ ├── Extensions
│ └── ClientExtensions.cs
│ ├── Factories
│ ├── GtmpVoice.cs
│ └── GtmpVoiceClientFactory.cs
│ ├── GtmpVoiceDelegates.cs
│ └── Interfaces
│ ├── IGtmpVoiceClient.cs
│ ├── IGtmpVoiceClientFactory.cs
│ └── IGtmpVoiceServer.cs
├── JustAnotherVoiceChat.Server.Testing
├── JustAnotherVoiceChat.Server.Testing.csproj
└── src
│ └── FakeAction.cs
├── JustAnotherVoiceChat.Server.Wrapper.Tests
├── JustAnotherVoiceChat.Server.Wrapper.Tests.csproj
└── src
│ ├── Fakes
│ ├── FakeVoiceClient.cs
│ ├── FakeVoiceClientFactory.cs
│ ├── FakeVoiceServer.cs
│ ├── Interfaces
│ │ └── IFakeVoiceClient.cs
│ └── VoiceWrapperEventInvoker.cs
│ ├── JustAnotherVoiceChatFixture.cs
│ ├── VectorFixture.cs
│ ├── VoiceServerClientFixtures.cs
│ ├── VoiceServerEventFixtures.cs
│ ├── VoiceServerFixtures.cs
│ └── VoiceServerNativeFixture.cs
├── JustAnotherVoiceChat.Server.Wrapper
├── JustAnotherVoiceChat.Server.Wrapper.csproj
├── Properties
│ └── AssemblyInfo.cs
└── src
│ ├── Delegates
│ ├── Delegates.cs
│ └── NativeDelegates.cs
│ ├── Elements
│ ├── Client
│ │ ├── VoiceClient.EventListener.cs
│ │ ├── VoiceClient.Muting.cs
│ │ ├── VoiceClient.Native.Positional.cs
│ │ └── VoiceClient.cs
│ ├── Models
│ │ ├── ClientConnectingEventArgs.cs
│ │ └── VoiceServerConfiguration.cs
│ ├── Server
│ │ ├── Helpers
│ │ │ └── VoiceTaskExecutor.cs
│ │ ├── VoiceServer.Clients.cs
│ │ ├── VoiceServer.Events.Dispatcher.cs
│ │ ├── VoiceServer.Events.Native.cs
│ │ ├── VoiceServer.Events.cs
│ │ ├── VoiceServer.Positional.cs
│ │ ├── VoiceServer.Tasks.cs
│ │ └── VoiceServer.cs
│ ├── Tasks
│ │ └── PositionalVoiceTask.cs
│ └── Wrapper
│ │ ├── NativeLibary.cs
│ │ ├── VoiceWrapper.Clients.cs
│ │ ├── VoiceWrapper.Events.cs
│ │ ├── VoiceWrapper.Muting.cs
│ │ ├── VoiceWrapper.Positional.cs
│ │ └── VoiceWrapper.Server.cs
│ ├── Enums
│ ├── LogLevel.cs
│ └── StatusCode.cs
│ ├── Exceptions
│ ├── ClientNotConnectedException.cs
│ ├── InvalidClientException.cs
│ ├── VoiceServerAlreadyStartedException.cs
│ └── VoiceServerNotStartedException.cs
│ ├── Interfaces
│ ├── IVoiceClient.cs
│ ├── IVoiceClientFactory.cs
│ ├── IVoiceServer.cs
│ ├── IVoiceTask.cs
│ ├── IVoiceTaskExecutor.cs
│ └── IVoiceWrapper.cs
│ ├── JustAnotherVoiceChat.cs
│ ├── Math
│ └── Vector3.cs
│ └── Structs
│ ├── ClientPosition.cs
│ └── VoiceHandle.cs
├── JustAnotherVoiceChat.Server.sln
├── JustAnotherVoiceChat.Server.sln.licenseheader
├── JustAnotherVoiceChat.Server
├── CMakeLists.txt
├── include
│ ├── api.h
│ ├── client.h
│ ├── internal.h
│ ├── justAnotherVoiceChat.h
│ ├── log.h
│ └── server.h
├── src
│ ├── CMakeLists.txt
│ ├── api.cpp
│ ├── client.cpp
│ ├── internal.cpp
│ ├── log.cpp
│ └── server.cpp
└── tests
│ ├── CMakeLists.txt
│ ├── test.cpp
│ ├── testClient.cpp
│ ├── testClient.h
│ ├── test_api.cpp
│ └── test_api.h
├── LICENSE
├── README.md
├── appveyor.yml
└── docs
├── communication.md
├── diagrams
├── client-communication.dia
├── connection-setup.dia
├── continues-communication.dia
├── general-communication.dia
└── network-communication.dia
├── images
├── JAVIC_Logo_Standalone_64px.png
├── JAVIC_Wide_250px.png
├── client-communication.png
├── connection-setup.png
├── continues-communication.png
├── general-communication.png
└── network-communication.png
└── installation-gtmp.md
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "JustAnotherVoiceChat.Server/thirdparty/enet"]
2 | path = JustAnotherVoiceChat.Server/thirdparty/enet
3 | url = https://github.com/lsalzman/enet.git
4 | [submodule "JustAnotherVoiceChat.Server/thirdparty/cereal"]
5 | path = JustAnotherVoiceChat.Server/thirdparty/cereal
6 | url = https://github.com/USCiLab/cereal.git
7 | [submodule "JustAnotherVoiceChat.Server/thirdparty/linalg"]
8 | path = JustAnotherVoiceChat.Server/thirdparty/linalg
9 | url = https://github.com/sgorsten/linalg.git
10 | [submodule "JustAnotherVoiceChat.Server/thirdparty/JustAnotherVoiceChat"]
11 | path = JustAnotherVoiceChat.Server/thirdparty/JustAnotherVoiceChat
12 | url = https://github.com/AlternateLife/JustAnotherVoiceChat.git
13 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os:
2 | - linux
3 | - osx
4 |
5 | compiler:
6 | - gcc
7 | - clang
8 |
9 | addons:
10 | apt:
11 | packages:
12 | texinfo
13 |
14 | language: cpp
15 | git:
16 | submodules: false
17 |
18 | before_install:
19 | - git config --global http.sslVerify "false"
20 | - git submodule update --init --recursive
21 | - git config --global http.sslVerify "true"
22 |
23 | script:
24 | - cd JustAnotherVoiceChat.Server
25 | - mkdir build
26 | - cd build
27 | - cmake ..
28 | - make
29 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Dummy/JustAnotherVoiceChat.Server.Dummy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug Windows
4 | Exe
5 | netcoreapp2.0
6 | 7
7 | false
8 | Debug Linux;Debug Windows;Release Linux;Release Windows
9 |
10 |
11 | TRACE;DEBUG;LINUX;NETCOREAPP2_0;NETCOREAPP2_0
12 | bin\Debug\Linux\
13 |
14 |
15 | TRACE;DEBUG;NETCOREAPP2_0
16 | bin\Debug\Windows\
17 |
18 |
19 | TRACE;RELEASE;NETCOREAPP2_0
20 | true
21 | bin\Release\Windows\
22 |
23 |
24 | TRACE;RELEASE;LINUX;NETCOREAPP2_0
25 | true
26 | bin\Release\Linux\
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | Always
37 |
38 |
39 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Dummy/nlog.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Dummy/src/Client/DummyClient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: DummyClient.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Client;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 | using JustAnotherVoiceChat.Server.Wrapper.Math;
31 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
32 |
33 | namespace JustAnotherVoiceChat.Server.Dummy.Client
34 | {
35 | public class DummyClient : VoiceClient
36 | {
37 | public override Vector3 Position { get; } = new Vector3(0, 1, 0);
38 |
39 | public DummyClient(IVoiceServer server, VoiceHandle handle) : base(server, handle)
40 | {
41 |
42 | }
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Dummy/src/Factories/DummyClientFactory.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: DummyClientFactory.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Dummy.Client;
29 | using JustAnotherVoiceChat.Server.Dummy.Interfaces;
30 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
32 |
33 | namespace JustAnotherVoiceChat.Server.Dummy.Repositories
34 | {
35 | public class DummyClientFactory : IDummyClientFactory
36 | {
37 | public DummyClient MakeClient(byte identifer, IVoiceServer server, VoiceHandle handle)
38 | {
39 | return new DummyClient(server, handle);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Dummy/src/Interfaces/IDummyClientRepository.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IDummyClientRepository.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Dummy.Client;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 |
31 | namespace JustAnotherVoiceChat.Server.Dummy.Interfaces
32 | {
33 | public interface IDummyClientFactory : IVoiceClientFactory
34 | {
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Dummy/src/ServerHandler.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ServerHandler.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Collections.Concurrent;
29 | using System.Threading;
30 | using JustAnotherVoiceChat.Server.Dummy.Client;
31 | using JustAnotherVoiceChat.Server.Dummy.Interfaces;
32 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
33 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Server;
34 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
35 | using NLog;
36 |
37 | namespace JustAnotherVoiceChat.Server.Dummy
38 | {
39 | public class ServerHandler : VoiceServer
40 | {
41 | private readonly Logger _logger = LogManager.GetCurrentClassLogger();
42 |
43 | private readonly ConcurrentBag _voiceClients = new ConcurrentBag();
44 |
45 | public ServerHandler(IDummyClientFactory clientRepository, VoiceServerConfiguration configuration) : base(clientRepository, configuration)
46 | {
47 | OnServerStarted += () =>
48 | {
49 | _logger.Debug($"JustAnotherVoiceChat: Listening on {Configuration.Hostname}:{Configuration.Port}");
50 | };
51 |
52 | OnServerStopping += () =>
53 | {
54 | _logger.Debug("JustAnotherVoiceChat: Stopping...");
55 | };
56 |
57 | OnClientConnected += c =>
58 | {
59 | _logger.Debug("Client connected: " + c.Handle.Identifer);
60 | };
61 | }
62 |
63 | public DummyClient PrepareClient()
64 | {
65 | return PrepareClient(1);
66 | }
67 |
68 | public void StartStresstest()
69 | {
70 | for (var i = 0; i < 20; i++)
71 | {
72 | new Thread(ClientPrepareThread).Start();
73 | }
74 | for (var i = 0; i < 20; i++)
75 | {
76 | new Thread(ClientRemoveThread).Start();
77 | }
78 | }
79 |
80 | public void ClientPrepareThread()
81 | {
82 | while (true)
83 | {
84 | var createdClient = PrepareClient();
85 |
86 | if (createdClient == null)
87 | {
88 | _logger.Warn("Failed to create client!");
89 | }
90 | else
91 | {
92 | _logger.Info("Created client: " + createdClient.Handle.Identifer);
93 | }
94 |
95 | _voiceClients.Add(createdClient);
96 |
97 | Thread.Sleep(1);
98 | }
99 | }
100 |
101 | public void ClientRemoveThread()
102 | {
103 | while (true)
104 | {
105 | Thread.Sleep(2);
106 |
107 | if (!_voiceClients.TryTake(out var client))
108 | {
109 | continue;
110 | }
111 |
112 | if (RemoveClient(client))
113 | {
114 | _logger.Info("Removed client: " + client.Handle.Identifer);
115 | }
116 | else
117 | {
118 | _logger.Warn("Failed to remove client: " + client.Handle.Identifer);
119 | }
120 | }
121 | }
122 |
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/JustAnotherVoiceChat.Server.GTMP.Resource.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006 Damien Miller (jBCrypt)
2 | Copyright (c) 2013 Ryan D. Emerle (.Net port)
3 |
4 | Permission to use, copy, modify, and distribute this software for any
5 | purpose with or without fee is hereby granted, provided that the above
6 | copyright notice and this permission notice appear in all copies.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: AssemblyInfo.cs
3 | * Date: 22.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Reflection;
29 | using System.Runtime.InteropServices;
30 |
31 | // General Information about an assembly is controlled through the following
32 | // set of attributes. Change these attribute values to modify the information
33 | // associated with an assembly.
34 | [assembly: AssemblyTitle("JustAnotherVoiceChat.Server.GTMP.Resource")]
35 | [assembly: AssemblyDescription("")]
36 | [assembly: AssemblyConfiguration("")]
37 | [assembly: AssemblyCompany("")]
38 | [assembly: AssemblyProduct("JustAnotherVoiceChat.Server.GTMP.Resource")]
39 | [assembly: AssemblyCopyright("Copyright © 2018")]
40 | [assembly: AssemblyTrademark("")]
41 | [assembly: AssemblyCulture("")]
42 |
43 | // Setting ComVisible to false makes the types in this assembly not visible
44 | // to COM components. If you need to access a type in this assembly from
45 | // COM, set the ComVisible attribute to true on that type.
46 | [assembly: ComVisible(false)]
47 |
48 | // The following GUID is for the ID of the typelib if this project is exposed to COM
49 | [assembly: Guid("62D8EA73-E9AA-435F-B58C-139C69507B26")]
50 |
51 | // Version information for an assembly consists of the following four values:
52 | //
53 | // Major Version
54 | // Minor Version
55 | // Build Number
56 | // Revision
57 | //
58 | // You can specify all the values or you can default the Build and Revision Numbers
59 | // by using the '*' as shown below:
60 | // [assembly: AssemblyVersion("1.0.*")]
61 | [assembly: AssemblyVersion("1.0.0.0")]
62 | [assembly: AssemblyFileVersion("1.0.0.0")]
63 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/Server/Helpers/RadioHandler.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: RadioHandler.cs
3 | * Date: 24.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using GrandTheftMultiplayer.Server.API;
30 | using GrandTheftMultiplayer.Server.Elements;
31 | using GrandTheftMultiplayer.Shared.Math;
32 | using JustAnotherVoiceChat.Server.GTMP.Extensions;
33 |
34 | namespace JustAnotherVoiceChat.Server.GTMP.Resource.Helpers
35 | {
36 | public class RadioHandler : Script
37 | {
38 |
39 | private const string RadioStatus = "RADIO_ACTIVE";
40 | private const string RadioChannel = "RADIO_CHANNEL";
41 |
42 | public bool EnableRadio(Client sender, string channel)
43 | {
44 | if (sender == null)
45 | {
46 | throw new ArgumentNullException(nameof(sender));
47 | }
48 |
49 | if (channel == null)
50 | {
51 | throw new ArgumentNullException(nameof(channel));
52 | }
53 |
54 | sender.setData(RadioStatus, true);
55 | sender.setData(RadioChannel, channel);
56 |
57 | return true;
58 | }
59 |
60 | public bool DisableRadio(Client sender)
61 | {
62 | if (sender == null)
63 | {
64 | throw new ArgumentNullException(nameof(sender));
65 | }
66 |
67 | sender.setData(RadioStatus, false);
68 | sender.setData(RadioChannel, "Off");
69 |
70 | return true;
71 | }
72 |
73 | public bool UseRadio(Client sender, string channel, bool decision)
74 | {
75 | if (sender == null)
76 | {
77 | throw new ArgumentNullException(nameof(sender));
78 | }
79 |
80 | if (channel == null)
81 | {
82 | throw new ArgumentNullException(nameof(channel));
83 | }
84 |
85 | if (channel == "Off")
86 | {
87 | return false;
88 | }
89 |
90 | if (decision == true)
91 | {
92 | foreach (var reciever in API.getAllPlayers())
93 | {
94 | if (reciever == null || reciever.IsNull)
95 | {
96 | continue;
97 | }
98 |
99 | if (reciever.getData(RadioChannel) == channel && reciever.getData(RadioStatus) == true)
100 | {
101 | reciever.SetRelativeSpeakerPosition(sender, new Vector3(1, 0, 0));
102 | }
103 | }
104 | }
105 | else
106 | {
107 | foreach (var reciever in API.getAllPlayers())
108 | {
109 | if (reciever == null || reciever.IsNull)
110 | {
111 | continue;
112 | }
113 |
114 | if (reciever.getData(RadioChannel) == channel && reciever.getData(RadioStatus) == true || reciever.hasData(RadioStatus) == false)
115 | {
116 | reciever.ResetRelativeSpeakerPosition(sender);
117 | }
118 | }
119 | }
120 |
121 | return true;
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/Server/VoiceScript.GtmpEvents.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceScript.GtmpEvents.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Constant;
29 | using GrandTheftMultiplayer.Server.Elements;
30 | using JustAnotherVoiceChat.Server.GTMP.Extensions;
31 |
32 | namespace JustAnotherVoiceChat.Server.GTMP.Resource
33 | {
34 | public partial class VoiceScript
35 | {
36 |
37 | private void AttachToGtmpEvents(bool testingEvents)
38 | {
39 | API.onClientEventTrigger += OnClientEventTrigger;
40 |
41 | if (testingEvents)
42 | {
43 | API.onPlayerFinishedDownload += OnPlayerFinishedDownload;
44 | }
45 | }
46 |
47 | private void OnPlayerFinishedDownload(Client player)
48 | {
49 | player.setSkin(PedHash.FreemodeMale01);
50 | }
51 |
52 | private void OnClientEventTrigger(Client sender, string eventName, params object[] arguments)
53 | {
54 | if (eventName != "VOICE_ROTATION")
55 | {
56 | return;
57 | }
58 |
59 | sender.SetVoiceRotation((float) arguments[0]);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/Server/VoiceScript.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceScript.cs
3 | * Date: 22.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.API;
29 | using JustAnotherVoiceChat.Server.GTMP.Elements.Tasks;
30 | using JustAnotherVoiceChat.Server.GTMP.Factories;
31 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
32 | using JustAnotherVoiceChat.Server.GTMP.Resource.Helpers;
33 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
34 |
35 | namespace JustAnotherVoiceChat.Server.GTMP.Resource
36 | {
37 | public partial class VoiceScript : Script
38 | {
39 |
40 | private IGtmpVoiceServer _voiceServer;
41 | private RadioHandler _radioHandler;
42 | private TelephoneHandler _phoneHandler;
43 |
44 | public VoiceScript()
45 | {
46 | API.onResourceStop += OnResourceStop;
47 | API.onResourceStart += OnResourceStart;
48 | }
49 |
50 | private void OnResourceStart()
51 | {
52 | // Create a JustAnotherVoiceServer based GtmpVoice Server!
53 | var hostname = API.getResourceSetting("justanothervoicechat", "voice_host");
54 | var port = API.getResourceSetting("justanothervoicechat", "voice_port");
55 |
56 | var teamspeakServerId = API.getResourceSetting("justanothervoicechat", "voice_teamspeak_serverid");
57 | var teamspeakChannelId = API.getResourceSetting("justanothervoicechat", "voice_teamspeak_channelid");
58 | var teamspeakChannelPassword = API.getResourceSetting("justanothervoicechat", "voice_teamspeak_channelpassword");
59 |
60 | _voiceServer = GtmpVoice.CreateServer(API, new VoiceServerConfiguration(hostname, port, teamspeakServerId, teamspeakChannelId, teamspeakChannelPassword));
61 |
62 | // Enables 3D Voice
63 | _voiceServer.AddTask(new GtmpPositionalTask());
64 |
65 | // Attach to some IVoiceServer events to react to certain them with certain actions.
66 | AttachToVoiceServerEvents();
67 |
68 | // Attach to GTMP-Events, so the connection works and camera rotation updates.
69 | AttachToGtmpEvents(true);
70 |
71 | _radioHandler = new RadioHandler();
72 | _phoneHandler = new TelephoneHandler(_voiceServer);
73 |
74 | // Startup VoiceServer, so players are able to connect.
75 | _voiceServer.Start();
76 | }
77 |
78 | private void OnResourceStop()
79 | {
80 | API.onResourceStop -= OnResourceStop;
81 | API.onResourceStart -= OnResourceStart;
82 |
83 | _radioHandler = null;
84 | _phoneHandler = null;
85 |
86 | _voiceServer.Stop();
87 | _voiceServer.Dispose();
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/meta.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP.Resource/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/JustAnotherVoiceChat.Server.GTMP.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | JustAnotherVoiceChat-Server GT-MP Integration
7 | JustAnotherVoiceChat contributors
8 | JustAnotherVoiceChat contributors
9 | https://github.com/AlternateLife/JustAnotherVoiceChat-Server/blob/master/LICENSE
10 | https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/master/docs/images/JAVIC_Logo_Standalone_64px.png
11 | https://github.com/AlternateLife/JustAnotherVoiceChat-Server
12 | JustAnotherVoiceChat.Server.GTMP is the integration of the JustanotherVoiceChat.Server into GT-MP
13 | 2018 JustAnotherVoiceChat
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006 Damien Miller (jBCrypt)
2 | Copyright (c) 2013 Ryan D. Emerle (.Net port)
3 |
4 | Permission to use, copy, modify, and distribute this software for any
5 | purpose with or without fee is hereby granted, provided that the above
6 | copyright notice and this permission notice appear in all copies.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: AssemblyInfo.cs
3 | * Date: 22.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Reflection;
29 | using System.Runtime.InteropServices;
30 |
31 | // General Information about an assembly is controlled through the following
32 | // set of attributes. Change these attribute values to modify the information
33 | // associated with an assembly.
34 | [assembly: AssemblyTitle("JustAnotherVoiceChat.Server.GTMP")]
35 | [assembly: AssemblyDescription("JustAnotherVoiceChat-Server is the control unit of the JustAnotherVoiceChat TeamSpeak3-Plugin. It uses a dedicated TeamSpeak3-Server to communicate with other players on any .NET based multiplayer-server.")]
36 | [assembly: AssemblyConfiguration("")]
37 | [assembly: AssemblyCompany("JustAnotherVoiceChat")]
38 | [assembly: AssemblyProduct("JustAnotherVoiceChat.Server.GTMP")]
39 | [assembly: AssemblyCopyright("Copyright © 2018")]
40 | [assembly: AssemblyTrademark("")]
41 | [assembly: AssemblyCulture("")]
42 |
43 | // Setting ComVisible to false makes the types in this assembly not visible
44 | // to COM components. If you need to access a type in this assembly from
45 | // COM, set the ComVisible attribute to true on that type.
46 | [assembly: ComVisible(false)]
47 |
48 | // The following GUID is for the ID of the typelib if this project is exposed to COM
49 | [assembly: Guid("7362E09D-6D62-493B-86FF-00544D5967F8")]
50 |
51 | // Version information for an assembly consists of the following four values:
52 | //
53 | // Major Version
54 | // Minor Version
55 | // Build Number
56 | // Revision
57 | //
58 | // You can specify all the values or you can default the Build and Revision Numbers
59 | // by using the '*' as shown below:
60 | // [assembly: AssemblyVersion("1.0.*")]
61 | [assembly: AssemblyVersion("1.0.0.0")]
62 | [assembly: AssemblyFileVersion("1.0.0.0")]
63 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Elements/Clients/GtmpVoiceClient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpVoiceClient.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Elements;
29 | using JustAnotherVoiceChat.Server.GTMP.Elements.Server;
30 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Client;
32 | using JustAnotherVoiceChat.Server.Wrapper.Math;
33 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
34 |
35 | namespace JustAnotherVoiceChat.Server.GTMP.Elements.Clients
36 | {
37 | internal class GtmpVoiceClient : VoiceClient, IGtmpVoiceClient
38 | {
39 | public Client Player { get; }
40 |
41 | public override Vector3 Position => new Vector3(Player.position.X, Player.position.Y, Player.position.Z);
42 | private new IGtmpVoiceServer Server => (IGtmpVoiceServer) base.Server;
43 |
44 | internal GtmpVoiceClient(Client player, GtmpVoiceServer server, VoiceHandle handle) : base(server, handle)
45 | {
46 | Player = player;
47 | }
48 |
49 | public bool SetRelativeSpeakerPosition(Client speaker, GrandTheftMultiplayer.Shared.Math.Vector3 position)
50 | {
51 | return SetRelativeSpeakerPosition(Server.GetVoiceClient(speaker), new Vector3(position.X, position.Y, position.Z));
52 | }
53 |
54 | public bool ResetRelativeSpeakerPosition(Client speaker)
55 | {
56 | return ResetRelativeSpeakerPosition(Server.GetVoiceClient(speaker));
57 | }
58 |
59 | public bool MuteSpeaker(Client speaker, bool muted)
60 | {
61 | return MuteSpeaker(Server.GetVoiceClient(speaker), muted);
62 | }
63 |
64 | public bool IsSpeakerMuted(Client speaker)
65 | {
66 | return IsSpeakerMuted(Server.GetVoiceClient(speaker));
67 | }
68 |
69 | public ClientPosition MakeClientPosition(GrandTheftMultiplayer.Shared.Math.Vector3 position, float rotation)
70 | {
71 | return MakeClientPosition(new Vector3(position.X, position.Y, position.Z), rotation);
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Elements/Server/GtmpVoiceServer.Events.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpVoiceServer.Events.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Constant;
29 | using GrandTheftMultiplayer.Server.Elements;
30 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Delegates;
32 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
33 |
34 | namespace JustAnotherVoiceChat.Server.GTMP.Elements.Server
35 | {
36 | public partial class GtmpVoiceServer
37 | {
38 |
39 | public new event Delegates.EmptyEvent OnServerStarted;
40 | public new event Delegates.EmptyEvent OnServerStopping;
41 |
42 | public event GtmpVoiceDelegates.GtmpVoiceClientEvent OnClientPrepared;
43 | public new event GtmpVoiceDelegates.GtmpVoiceLogMessageEvent OnLogMessage;
44 |
45 | private void AttachToEvents()
46 | {
47 | _api.onPlayerFinishedDownload += OnPlayerConnect;
48 | _api.onPlayerDisconnected += OnPlayerDisconnect;
49 |
50 | base.OnServerStarted += OnVoiceServerStarted;
51 | base.OnServerStopping += OnVoiceServerStopping;
52 | base.OnLogMessage += OnVoiceServerLogMessage;
53 | }
54 |
55 | private void OnVoiceServerLogMessage(string message, LogLevel logLevel)
56 | {
57 | LogCat logCat;
58 | switch (logLevel)
59 | {
60 | case LogLevel.Trace:
61 | logCat = LogCat.Trace;
62 | break;
63 | case LogLevel.Debug:
64 | logCat = LogCat.Debug;
65 | break;
66 | case LogLevel.Warning:
67 | logCat = LogCat.Warn;
68 | break;
69 | case LogLevel.Error:
70 | logCat = LogCat.Error;
71 | break;
72 | default:
73 | logCat = LogCat.Info;
74 | break;
75 | }
76 |
77 | OnLogMessage?.Invoke(logCat, message);
78 | }
79 |
80 | private void OnVoiceServerStarted()
81 | {
82 | foreach (var player in _api.getAllPlayers())
83 | {
84 | RegisterPlayer(player);
85 | }
86 |
87 | OnServerStarted?.Invoke();
88 | }
89 |
90 | private void OnVoiceServerStopping()
91 | {
92 | foreach (var client in GetClients())
93 | {
94 | UnregisterPlayer(client.Player);
95 | }
96 |
97 | OnServerStopping?.Invoke();
98 | }
99 |
100 | private void OnPlayerConnect(Client player)
101 | {
102 | if (RegisterPlayer(player) != null)
103 | {
104 | return;
105 | }
106 |
107 | player.kick("Failed to start VoiceClient!");
108 | _api.consoleOutput(LogCat.Error, $"Failed to start VoiceClient for Client {player.name}");
109 | }
110 |
111 | private void OnPlayerDisconnect(Client player, string reason)
112 | {
113 | UnregisterPlayer(player);
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Elements/Server/GtmpVoiceServer.Players.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpVoiceServer.Players.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using GrandTheftMultiplayer.Server.Elements;
30 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
31 |
32 | namespace JustAnotherVoiceChat.Server.GTMP.Elements.Server
33 | {
34 | public partial class GtmpVoiceServer
35 | {
36 | private const string PlayerDataKey = "JV_HANDLE";
37 |
38 | public IGtmpVoiceClient GetVoiceClient(Client player)
39 | {
40 | if (player.hasData(PlayerDataKey))
41 | {
42 | return (IGtmpVoiceClient) player.getData(PlayerDataKey);
43 | }
44 |
45 | return FindClient(c => c.Player == player);
46 | }
47 |
48 | private IGtmpVoiceClient RegisterPlayer(Client player)
49 | {
50 | var voiceClient = PrepareClient(player);
51 | if (voiceClient == null)
52 | {
53 | return null;
54 | }
55 |
56 | player.setData(PlayerDataKey, voiceClient);
57 |
58 | OnClientPrepared?.Invoke(voiceClient);
59 |
60 | return voiceClient;
61 | }
62 |
63 | private void UnregisterPlayer(Client player)
64 | {
65 | if (player == null)
66 | {
67 | throw new ArgumentNullException(nameof(player));
68 | }
69 |
70 | var client = GetVoiceClient(player);
71 | if (client != null)
72 | {
73 | RemoveClient(client);
74 | client.Player.resetData(PlayerDataKey);
75 | }
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Elements/Server/GtmpVoiceServer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpVoiceServer.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.API;
29 | using GrandTheftMultiplayer.Server.Elements;
30 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
32 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Server;
33 |
34 | namespace JustAnotherVoiceChat.Server.GTMP.Elements.Server
35 | {
36 | public partial class GtmpVoiceServer : VoiceServer, IGtmpVoiceServer
37 | {
38 | private readonly API _api;
39 |
40 | protected internal GtmpVoiceServer(API api, IGtmpVoiceClientFactory clientRepository, VoiceServerConfiguration configuration) : base(clientRepository, configuration)
41 | {
42 | _api = api;
43 |
44 | AttachToEvents();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Elements/Tasks/GtmpPositionalTask.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpPositionalTask.cs
3 | * Date: 27.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Linq;
29 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
30 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
31 |
32 | namespace JustAnotherVoiceChat.Server.GTMP.Elements.Tasks
33 | {
34 | public class GtmpPositionalTask : IVoiceTask
35 | {
36 | private readonly int _sleepTime;
37 |
38 | public GtmpPositionalTask(int sleepTime = 125)
39 | {
40 | _sleepTime = sleepTime;
41 | }
42 |
43 | public virtual int RunVoiceTask(IVoiceServer server)
44 | {
45 | var clientPositions = server.GetClients().Select(client =>
46 | {
47 | if (client.Player.vehicle == null)
48 | {
49 | return client.MakeClientPosition();
50 | }
51 | else
52 | {
53 | return client.MakeClientPosition(client.Player.vehicle.position, client.CameraRotation);
54 | }
55 | });
56 |
57 | server.SetPlayerPositions(clientPositions);
58 |
59 | return _sleepTime;
60 | }
61 |
62 | public virtual void Dispose()
63 | {
64 |
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Exceptions/ServerNotSharedException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ServerNotSharedException.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 |
30 | namespace JustAnotherVoiceChat.Server.GTMP.Exceptions
31 | {
32 | public class ServerNotSharedException : Exception
33 | {
34 |
35 | internal ServerNotSharedException() : base("This feature is only available if the shared GtmpVoice-Server is set")
36 | {
37 |
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Extensions/ClientExtensions.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ClientExtensions.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Elements;
29 | using GrandTheftMultiplayer.Shared.Math;
30 | using JustAnotherVoiceChat.Server.GTMP.Exceptions;
31 | using JustAnotherVoiceChat.Server.GTMP.Factories;
32 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
33 |
34 | namespace JustAnotherVoiceChat.Server.GTMP.Extensions
35 | {
36 | public static class ClientExtensions
37 | {
38 |
39 | private static IGtmpVoiceServer Server => GtmpVoice.Shared;
40 |
41 | public static IGtmpVoiceClient GetVoiceClient(this Client client)
42 | {
43 | if (Server == null)
44 | {
45 | throw new ServerNotSharedException();
46 | }
47 |
48 | return Server.GetVoiceClient(client);
49 | }
50 |
51 | public static void SetVoiceRotation(this Client client, float rotation)
52 | {
53 | var voiceClient = client.GetVoiceClient();
54 | if (voiceClient != null)
55 | {
56 | voiceClient.CameraRotation = rotation;
57 | }
58 | }
59 |
60 | public static void SetVoiceRange(this Client listener, float range)
61 | {
62 | listener.GetVoiceClient()?.SetVoiceRange(range);
63 | }
64 |
65 | public static bool SetListeningPosition(this Client listener, Vector3 position, float rotation)
66 | {
67 | return listener.GetVoiceClient()?.SetListeningPosition(new Wrapper.Math.Vector3(position.X, position.Y, position.Z), rotation) ?? false;
68 | }
69 |
70 | public static bool SetRelativeSpeakerPosition(this Client listener, Client speaker, Vector3 position)
71 | {
72 | return listener.GetVoiceClient()?.SetRelativeSpeakerPosition(speaker, position) ?? false;
73 | }
74 |
75 | public static bool ResetRelativeSpeakerPosition(this Client listener, Client speaker)
76 | {
77 | return listener.GetVoiceClient()?.ResetRelativeSpeakerPosition(speaker) ?? false;
78 | }
79 |
80 | public static bool ResetAllRelativeSpeakerPositions(this Client listener)
81 | {
82 | return listener.GetVoiceClient()?.ResetAllRelativeSpeakerPositions() ?? false;
83 | }
84 |
85 | public static bool MuteForAll(this Client listener, bool muted)
86 | {
87 | return listener.GetVoiceClient()?.MuteForAll(muted) ?? false;
88 | }
89 |
90 | public static bool IsMutedForAll(this Client listener)
91 | {
92 | return listener.GetVoiceClient()?.IsMutedForAll() ?? false;
93 | }
94 |
95 | public static bool MuteSpeaker(this Client listener, Client speaker, bool muted)
96 | {
97 | return listener.GetVoiceClient()?.MuteSpeaker(speaker, muted) ?? false;
98 | }
99 |
100 | public static bool IsSpeakerMuted(this Client listener, Client speaker)
101 | {
102 | return listener.GetVoiceClient()?.IsSpeakerMuted(speaker) ?? false;
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Factories/GtmpVoice.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpVoice.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.API;
29 | using JustAnotherVoiceChat.Server.GTMP.Elements.Server;
30 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
32 |
33 | namespace JustAnotherVoiceChat.Server.GTMP.Factories
34 | {
35 | public static class GtmpVoice
36 | {
37 | private static IGtmpVoiceServer _shared;
38 |
39 | public static IGtmpVoiceServer Shared
40 | {
41 | get => _shared;
42 | set
43 | {
44 | if (_shared != null)
45 | {
46 | return;
47 | }
48 |
49 | _shared = value;
50 | }
51 | }
52 |
53 | public static IGtmpVoiceServer CreateServer(API api, VoiceServerConfiguration configuration, bool setShared = true)
54 | {
55 | if (Shared != null)
56 | {
57 | return Shared;
58 | }
59 |
60 | var server = new GtmpVoiceServer(api, new GtmpVoiceClientFactory(), configuration);
61 | if (setShared)
62 | {
63 | Shared = server;
64 | }
65 |
66 | return server;
67 | }
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Factories/GtmpVoiceClientFactory.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpVoiceClientFactory.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Elements;
29 | using JustAnotherVoiceChat.Server.GTMP.Elements.Clients;
30 | using JustAnotherVoiceChat.Server.GTMP.Elements.Server;
31 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
32 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
33 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
34 |
35 | namespace JustAnotherVoiceChat.Server.GTMP.Factories
36 | {
37 | internal class GtmpVoiceClientFactory : IGtmpVoiceClientFactory
38 | {
39 | public IGtmpVoiceClient MakeClient(Client player, IVoiceServer server, VoiceHandle handle)
40 | {
41 | return new GtmpVoiceClient(player, (GtmpVoiceServer) server, handle);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/GtmpVoiceDelegates.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: GtmpVoiceDelegates.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Constant;
29 | using JustAnotherVoiceChat.Server.GTMP.Interfaces;
30 |
31 | namespace JustAnotherVoiceChat.Server.GTMP
32 | {
33 | public static class GtmpVoiceDelegates
34 | {
35 |
36 | public delegate void GtmpVoiceClientEvent(IGtmpVoiceClient client);
37 | public delegate void GtmpVoiceClientStatusEvent(IGtmpVoiceClient client, bool newStatus);
38 |
39 | public delegate void GtmpVoiceLogMessageEvent(LogCat category, string message);
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Interfaces/IGtmpVoiceClient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IGtmpVoiceClient.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Elements;
29 | using GrandTheftMultiplayer.Shared.Math;
30 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
32 |
33 | namespace JustAnotherVoiceChat.Server.GTMP.Interfaces
34 | {
35 | public interface IGtmpVoiceClient : IVoiceClient
36 | {
37 |
38 | Client Player { get; }
39 |
40 | bool SetRelativeSpeakerPosition(Client speaker, Vector3 position);
41 | bool ResetRelativeSpeakerPosition(Client speaker);
42 |
43 | bool MuteSpeaker(Client speaker, bool muted);
44 | bool IsSpeakerMuted(Client speaker);
45 |
46 | ClientPosition MakeClientPosition(Vector3 position, float rotation);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Interfaces/IGtmpVoiceClientFactory.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IGtmpVoiceClientFactory.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Elements;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 |
31 | namespace JustAnotherVoiceChat.Server.GTMP.Interfaces
32 | {
33 | public interface IGtmpVoiceClientFactory : IVoiceClientFactory
34 | {
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.GTMP/src/Interfaces/IGtmpVoiceServer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IGtmpVoiceServer.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using GrandTheftMultiplayer.Server.Elements;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 |
31 | namespace JustAnotherVoiceChat.Server.GTMP.Interfaces
32 | {
33 | public interface IGtmpVoiceServer : IVoiceServer
34 | {
35 | event GtmpVoiceDelegates.GtmpVoiceClientEvent OnClientPrepared;
36 | new event GtmpVoiceDelegates.GtmpVoiceLogMessageEvent OnLogMessage;
37 |
38 | IGtmpVoiceClient GetVoiceClient(Client player);
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Testing/JustAnotherVoiceChat.Server.Testing.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard1.2
4 | false
5 | Debug Windows
6 |
7 |
8 | 0
9 | bin\Debug\Linux\
10 | TRACE;DEBUG;LINUX;NETSTANDARD1_2
11 |
12 |
13 | bin\Debug\Windows\
14 | TRACE;DEBUG;NETSTANDARD1_2
15 |
16 |
17 | bin\Release\Windows\
18 | TRACE;NETSTANDARD1_2
19 | true
20 |
21 |
22 | bin\Release\Linux\
23 | TRACE;LINUX;NETSTANDARD1_2
24 | true
25 |
26 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Testing/src/FakeAction.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: FakeAction.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 |
30 | namespace JustAnotherVoiceChat.Server.Testing
31 | {
32 | public class FakeAction
33 | {
34 |
35 | public int InvokeAmount { get; private set; }
36 | public Action Action { get; }
37 |
38 | public FakeAction()
39 | {
40 | Action = e => InvokeAmount++;
41 | }
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper.Tests/JustAnotherVoiceChat.Server.Wrapper.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug Windows
4 | netcoreapp2.0
5 | false
6 | Debug Linux;Debug Windows;Release Linux;Release Windows
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 0
20 | bin\Debug\Linux\
21 | TRACE;DEBUG;LINUX;NETCOREAPP2_0
22 |
23 |
24 | bin\Debug\Windows\
25 | TRACE;DEBUG;NETCOREAPP2_0
26 |
27 |
28 | bin\Release\Windows\
29 | TRACE;NETCOREAPP2_0
30 | true
31 |
32 |
33 | bin\Release\Linux\
34 | TRACE;LINUX;NETCOREAPP2_0
35 | true
36 |
37 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper.Tests/src/Fakes/FakeVoiceClient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: FakeVoiceClient.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Client;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 | using JustAnotherVoiceChat.Server.Wrapper.Math;
31 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
32 | using JustAnotherVoiceChat.Server.Wrapper.Tests.Fakes.Interfaces;
33 |
34 | namespace JustAnotherVoiceChat.Server.Wrapper.Tests.Fakes
35 | {
36 | public class FakeVoiceClient : VoiceClient, IFakeVoiceClient
37 | {
38 | public byte Identifer { get; }
39 |
40 | public FakeVoiceClient(byte identifer, IVoiceServer server, VoiceHandle handle) : base(server, handle)
41 | {
42 | Identifer = identifer;
43 | }
44 |
45 | public override Vector3 Position { get; } = new Vector3();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper.Tests/src/Fakes/FakeVoiceClientFactory.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: FakeVoiceClientFactory.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
29 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
30 | using JustAnotherVoiceChat.Server.Wrapper.Tests.Fakes.Interfaces;
31 |
32 | namespace JustAnotherVoiceChat.Server.Wrapper.Tests.Fakes
33 | {
34 | public class FakeVoiceClientFactory : IVoiceClientFactory
35 | {
36 | public IFakeVoiceClient MakeClient(byte identifier, IVoiceServer server, VoiceHandle handle)
37 | {
38 | return new FakeVoiceClient(identifier, server, handle);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper.Tests/src/Fakes/FakeVoiceServer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: FakeVoiceServer.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
29 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Server;
30 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Tests.Fakes.Interfaces;
32 |
33 | namespace JustAnotherVoiceChat.Server.Wrapper.Tests.Fakes
34 | {
35 | internal class FakeVoiceServer : VoiceServer
36 | {
37 | public FakeVoiceServer(IVoiceClientFactory factory, VoiceServerConfiguration configuration, IVoiceWrapper voiceWrapper = null) : base(factory, configuration, voiceWrapper)
38 | {
39 |
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper.Tests/src/Fakes/Interfaces/IFakeVoiceClient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IFakeVoiceClient.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Tests.Fakes.Interfaces
31 | {
32 | public interface IFakeVoiceClient : IVoiceClient
33 | {
34 | byte Identifer { get; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper.Tests/src/JustAnotherVoiceChatFixture.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: JustAnotherVoiceChatFixture.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
29 | using NUnit.Framework;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper.Tests
32 | {
33 | [TestFixture]
34 | public class JustAnotherVoiceChatFixture
35 | {
36 | [Test]
37 | public void GetVoiceWrapperWillReturnsAnIVoiceWrapperInstance()
38 | {
39 | var voiceWrapper = JustAnotherVoiceChat.GetVoiceWrapper();
40 | Assert.IsInstanceOf(voiceWrapper);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/JustAnotherVoiceChat.Server.Wrapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug Windows
4 | 1.0.0.0
5 | netstandard1.2
6 | $(VoiceChatVersion)
7 | $(VoiceChatVersion)
8 | $(VoiceChatVersion)
9 | 7
10 | Debug Linux;Debug Windows;Release Linux;Release Windows
11 | JustAnotherVoiceChat-Server .NET Standard Wrapper
12 | JustAnotherVoiceChat-Server is the control unit of the JustAnotherVoiceChat TeamSpeak3-Plugin. It uses a dedicated TeamSpeak3-Server to communicate with other players on any .NET based multiplayer-server.
13 | 2018 JustAnotherVoiceChat
14 | JustAnotherVoiceChat
15 | https://github.com/AlternateLife/JustAnotherVoiceChat-Server/blob/master/LICENSE
16 | https://github.com/AlternateLife/JustAnotherVoiceChat-Server
17 | https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/master/docs/images/JAVIC_Logo_Standalone_64px.png
18 | https://github.com/AlternateLife/JustAnotherVoiceChat-Server
19 | git
20 | JustAnotherVoiceChat contributors
21 | true
22 |
23 |
24 | 0
25 | true
26 | bin\Debug\Linux\
27 | TRACE;DEBUG;LINUX;NETSTANDARD1_2
28 |
29 |
30 | bin\Debug\Windows\
31 | TRACE;DEBUG;NETSTANDARD1_2
32 | true
33 |
34 |
35 | true
36 | bin\Release\Windows\
37 | TRACE;NETSTANDARD1_2
38 | true
39 |
40 |
41 | true
42 | bin\Release\Linux\
43 | TRACE;LINUX;NETSTANDARD1_2
44 | true
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | Always
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | Always
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: AssemblyInfo.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Runtime.CompilerServices;
29 |
30 | [assembly: InternalsVisibleTo("JustAnotherVoiceChat.Server.Wrapper.Tests")]
31 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Delegates/Delegates.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: Delegates.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
29 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
30 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
31 |
32 | namespace JustAnotherVoiceChat.Server.Wrapper.Delegates
33 | {
34 | public class Delegates where TClient : IVoiceClient
35 | {
36 | public delegate void EmptyEvent();
37 |
38 | public delegate void ClientEvent(TClient voiceClient);
39 | public delegate void ClientConnectingEvent(TClient voiceClient, string teamspeakId, ClientConnectingEventArgs eventArgs);
40 |
41 | public delegate void ClientStatusEvent(TClient voiceClient, bool newStatus);
42 | public delegate void ClientMuteStatusEvent(TClient voiceClient, bool isMuted);
43 | public delegate void ClientRejectedEvent(TClient voiceClient, StatusCode statusCode);
44 | public delegate void LogMessageEvent(string message, LogLevel logLevel);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Delegates/NativeDelegates.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: NativeDelegates.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | namespace JustAnotherVoiceChat.Server.Wrapper.Delegates
29 | {
30 | public class NativeDelegates
31 | {
32 | public delegate void ClientCallback(ushort handle);
33 | public delegate bool ClientConnectingCallback(ushort handle, string teamspeakId);
34 | public delegate void ClientStatusCallback(ushort handle, bool newStatus);
35 | public delegate void ClientRejectedCallback(ushort handle, int statusCode);
36 |
37 | public delegate void LogMessageCallback(string message, int loglevel);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Client/VoiceClient.EventListener.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceClient.EventListener.cs
3 | * Date: 24.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Client
32 | {
33 | public partial class VoiceClient where TClient : IVoiceClient
34 | {
35 |
36 | private void AttachToStatusChangeEvents()
37 | {
38 | Server.OnClientMicrophoneMuteChanged += OnClientMicrophoneChanged;
39 | Server.OnClientSpeakersMuteChanged += OnClientSpeakersMuteChanged;
40 | }
41 |
42 | private void DetachFromStatusChangeEvents()
43 | {
44 | Server.OnClientMicrophoneMuteChanged -= OnClientMicrophoneChanged;
45 | Server.OnClientSpeakersMuteChanged -= OnClientSpeakersMuteChanged;
46 | }
47 |
48 | private void OnClientSpeakersMuteChanged(TClient client, bool isMuted)
49 | {
50 | ExecuteOnMe(client, () => { Speakers = !isMuted; });
51 | }
52 |
53 | private void OnClientMicrophoneChanged(TClient client, bool isMuted)
54 | {
55 | ExecuteOnMe(client, () => { Microphone = !isMuted; });
56 | }
57 |
58 | private void ExecuteOnMe(TClient client, Action callback)
59 | {
60 | if (!ReferenceEquals(this, client))
61 | {
62 | return;
63 | }
64 |
65 | callback();
66 | }
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Client/VoiceClient.Muting.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceClient.Muting.cs
3 | * Date: 25.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
29 | using System;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Client
32 | {
33 | public partial class VoiceClient where TClient : IVoiceClient
34 | {
35 |
36 | public bool MuteForAll(bool muted)
37 | {
38 | return RunWhenConnected(() => Server.NativeWrapper.MuteClientForAll(this, muted));
39 | }
40 |
41 | public bool IsMutedForAll()
42 | {
43 | return RunWhenConnected(() => Server.NativeWrapper.IsClientMutedForAll(this));
44 | }
45 |
46 | public bool MuteSpeaker(IVoiceClient speaker, bool muted)
47 | {
48 | if (speaker == null)
49 | {
50 | throw new ArgumentNullException(nameof(speaker));
51 | }
52 |
53 | return RunWhenConnected(() => Server.NativeWrapper.MuteClientForClient(speaker, this, muted));
54 | }
55 |
56 | public bool IsSpeakerMuted(IVoiceClient speaker)
57 | {
58 | if (speaker == null)
59 | {
60 | throw new ArgumentNullException(nameof(speaker));
61 | }
62 |
63 | return RunWhenConnected(() => Server.NativeWrapper.IsClientMutedForClient(speaker, this));
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Client/VoiceClient.Native.Positional.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceClient.Native.Positional.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Collections.Generic;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 | using JustAnotherVoiceChat.Server.Wrapper.Math;
31 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
32 |
33 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Client
34 | {
35 | public partial class VoiceClient where TClient : IVoiceClient
36 | {
37 | public bool SetListeningPosition(Vector3 position, float rotation)
38 | {
39 | return RunWhenConnected(() => Server.NativeWrapper.SetListenerPosition(this, position, rotation));
40 | }
41 |
42 | public ClientPosition MakeClientPosition(Vector3 position, float rotation)
43 | {
44 | return new ClientPosition(Handle.Identifer, position.X, position.Y, position.Z, rotation);
45 | }
46 |
47 | public ClientPosition MakeClientPosition()
48 | {
49 | var position = Position;
50 | return new ClientPosition(Handle.Identifer, position.X, position.Y, position.Z, CameraRotation);
51 | }
52 |
53 | public bool SetRelativeSpeakerPosition(IVoiceClient speaker, Vector3 position)
54 | {
55 | return RunWhenConnected(() => Server.NativeWrapper.SetRelativeSpeakerPositionForListener(this, speaker, position));
56 | }
57 |
58 | public bool ResetRelativeSpeakerPosition(IVoiceClient speaker)
59 | {
60 | return RunWhenConnected(() => Server.NativeWrapper.ResetRelativeSpeakerPositionForListener(this, speaker));
61 | }
62 |
63 | public bool ResetAllRelativeSpeakerPositions()
64 | {
65 | return RunWhenConnected(() => Server.NativeWrapper.ResetAllRelativePositionsForListener(this));
66 | }
67 |
68 | public bool SetVoiceRange(float range)
69 | {
70 | return RunWhenConnected(() => Server.NativeWrapper.SetClientVoiceRange(this, range));
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Client/VoiceClient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceClient.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Exceptions;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 | using JustAnotherVoiceChat.Server.Wrapper.Math;
31 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
32 | using System;
33 |
34 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Client
35 | {
36 | public abstract partial class VoiceClient : IVoiceClient where TClient : IVoiceClient
37 | {
38 | protected readonly IVoiceServer Server;
39 |
40 | public VoiceHandle Handle { get; }
41 |
42 | public bool Microphone { get; private set; }
43 | public bool Speakers { get; private set; }
44 |
45 | public abstract Vector3 Position { get; }
46 | public float CameraRotation { get; set; }
47 |
48 | public string HandshakeUrl { get; }
49 |
50 | public bool Connected => Server.NativeWrapper.IsClientConnected(this);
51 |
52 | protected VoiceClient(IVoiceServer server, VoiceHandle handle)
53 | {
54 | Server = server;
55 | Handle = handle;
56 |
57 | Speakers = true;
58 | Microphone = true;
59 |
60 | var config = Server.Configuration;
61 | HandshakeUrl = $"http://localhost:23333/?host={config.Hostname}&port={config.Port}&uid={Handle.Identifer}";
62 |
63 | AttachToStatusChangeEvents();
64 | }
65 |
66 | public bool SetNickname(string nickname)
67 | {
68 | return Server.NativeWrapper.SetClientNickname(this, nickname);
69 | }
70 |
71 | private T RunWhenConnected(Func callback)
72 | {
73 | if (!Connected)
74 | {
75 | return default(T);
76 | }
77 |
78 | return callback();
79 | }
80 |
81 | public void Dispose()
82 | {
83 | DetachFromStatusChangeEvents();
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Models/ClientConnectingEventArgs.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ClientConnectingEventArgs.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Models
31 | {
32 | public class ClientConnectingEventArgs : EventArgs
33 | {
34 |
35 | public bool Reject { get; set; }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Models/VoiceServerConfiguration.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceServerConfiguration.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using JustAnotherVoiceChat.Server.Wrapper.Exceptions;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Models
32 | {
33 | public class VoiceServerConfiguration
34 | {
35 |
36 | public string Hostname { get; }
37 | public ushort Port { get; }
38 |
39 | public string TeamspeakServerId { get; }
40 | public ulong TeamspeakChannelId { get; }
41 | public string TeamspeakChannelPassword { get; }
42 |
43 | public float GlobalRollOffScale { get; }
44 | public float GlobalDistanceFactor { get; }
45 | public double GlobalMaxDistance { get; }
46 |
47 | public VoiceServerConfiguration(string hostname, ushort port, string teamspeakServerId, ulong teamspeakChannelId, string teamspeakChannelPassword)
48 | : this(hostname, port, teamspeakServerId, teamspeakChannelId, teamspeakChannelPassword, 1, 1, 10f)
49 | {
50 | }
51 |
52 | public VoiceServerConfiguration(string hostname, ushort port, string teamspeakServerId, ulong teamspeakChannelId, string teamspeakChannelPassword, float globalRollOffScale, float globalDistanceFactor, double globalMaxDistance)
53 | {
54 | if (string.IsNullOrWhiteSpace(hostname) || Uri.CheckHostName(hostname) == UriHostNameType.Unknown)
55 | {
56 | throw new ArgumentException($"The provided hostname \"{hostname}\" is invalid!");
57 | }
58 |
59 | if (string.IsNullOrWhiteSpace(teamspeakServerId))
60 | {
61 | throw new ArgumentException($"The provided teamspeakServerId \"{teamspeakServerId}\" is invalid!");
62 | }
63 |
64 | Hostname = hostname;
65 | Port = port;
66 |
67 | TeamspeakServerId = teamspeakServerId;
68 | TeamspeakChannelId = teamspeakChannelId;
69 | TeamspeakChannelPassword = teamspeakChannelPassword;
70 |
71 | GlobalRollOffScale = globalRollOffScale;
72 | GlobalDistanceFactor = globalDistanceFactor;
73 | GlobalMaxDistance = globalMaxDistance;
74 | }
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Server/Helpers/VoiceTaskExecutor.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceTaskExecutor.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using System.Threading;
30 | using System.Threading.Tasks;
31 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
32 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
33 |
34 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Server.Helpers
35 | {
36 | internal class VoiceTaskExecutor : IVoiceTaskExecutor where TClient : IVoiceClient
37 | {
38 |
39 | private readonly IVoiceTask _voiceTask;
40 | private readonly IVoiceServer _voiceServer;
41 |
42 | private CancellationTokenSource _cancellationTokenSource;
43 |
44 | private Task _task;
45 |
46 | private bool _isRunning;
47 |
48 | internal VoiceTaskExecutor(IVoiceTask voiceTask, IVoiceServer voiceServer)
49 | {
50 | _voiceTask = voiceTask;
51 | _voiceServer = voiceServer;
52 | }
53 |
54 | public void Start()
55 | {
56 | if (_isRunning)
57 | {
58 | throw new InvalidOperationException("The task is already running!");
59 | }
60 |
61 | if (_cancellationTokenSource == null)
62 | {
63 | _cancellationTokenSource = new CancellationTokenSource();
64 | }
65 |
66 | _isRunning = true;
67 |
68 | var token = _cancellationTokenSource.Token;
69 | _task = Task.Run(async () =>
70 | {
71 | while (true)
72 | {
73 | token.ThrowIfCancellationRequested();
74 |
75 | int waitTime;
76 | try
77 | {
78 | waitTime = _voiceTask.RunVoiceTask(_voiceServer);
79 | }
80 | catch (Exception e)
81 | {
82 | waitTime = 1000;
83 | _voiceServer.Log(LogLevel.Error, "Exception in VoiceTask: " + e);
84 | }
85 |
86 | await Task.Delay(waitTime, token);
87 | }
88 | }, token);
89 | }
90 |
91 | public void Stop()
92 | {
93 | if (!_isRunning)
94 | {
95 | throw new InvalidOperationException("The task is currently not running!");
96 | }
97 |
98 | try
99 | {
100 | _cancellationTokenSource.Cancel();
101 | _cancellationTokenSource.Dispose();
102 |
103 | _cancellationTokenSource = null;
104 | }
105 | catch (AggregateException e)
106 | {
107 | _voiceServer.Log(LogLevel.Error, "The following exceptions were thrown in task: " + e);
108 | }
109 | }
110 |
111 | public void Dispose()
112 | {
113 | if (_cancellationTokenSource != null)
114 | {
115 | _cancellationTokenSource.Dispose();
116 | _cancellationTokenSource = null;
117 | }
118 |
119 | _task = null;
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Server/VoiceServer.Events.Native.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceServer.Events.Native.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using System.Collections.Generic;
30 | using System.Runtime.InteropServices;
31 | using JustAnotherVoiceChat.Server.Wrapper.Delegates;
32 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
33 |
34 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Server
35 | {
36 | public partial class VoiceServer where TClient : IVoiceClient
37 | {
38 | private readonly List _garbageCollectorHandles = new List();
39 |
40 | internal void RegisterEvent(Action register, T callback)
41 | {
42 | _garbageCollectorHandles.Add(GCHandle.Alloc(callback));
43 |
44 | register(callback);
45 | }
46 |
47 | private void AttachToNativeEvents()
48 | {
49 | RegisterEvent(NativeWrapper.RegisterClientConnectingCallback, OnClientConnectingFromVoice);
50 | RegisterEvent(NativeWrapper.RegisterClientConnectedCallback, OnClientConnectedFromVoice);
51 | RegisterEvent(NativeWrapper.RegisterClientDisconnectedCallback, OnClientDisconnectedFromVoice);
52 | RegisterEvent(NativeWrapper.RegisterClientRejectedCallback, OnClientRejectedFromVoice);
53 | RegisterEvent(NativeWrapper.RegisterClientTalkingChangedCallback, OnClientTalkingStatusChangedFromVoice);
54 | RegisterEvent(NativeWrapper.RegisterClientSpeakersMuteChangedCallback, OnClientSpeakersMuteChangedFromVoice);
55 | RegisterEvent(NativeWrapper.RegisterClientMicrophoneMuteChangedCallback, OnClientMicrophoneMuteChangedFromVoice);
56 | RegisterEvent(NativeWrapper.RegisterLogMessageCallback, OnLogMessageFromVoice);
57 | }
58 |
59 | private void DisposeNativeEvents()
60 | {
61 | NativeWrapper.UnregisterClientConnectedCallback();
62 | NativeWrapper.UnregisterClientConnectingCallback();
63 | NativeWrapper.UnregisterClientDisconnectedCallback();
64 | NativeWrapper.UnregisterClientRejectedCallback();
65 |
66 | NativeWrapper.UnregisterClientTalkingChangedCallback();
67 | NativeWrapper.UnregisterClientSpeakersMuteChangedCallback();
68 | NativeWrapper.UnregisterClientMicrophoneMuteChangedCallback();
69 |
70 | NativeWrapper.UnregisterLogMessageCallback();
71 |
72 | foreach (var handle in _garbageCollectorHandles)
73 | {
74 | handle.Free();
75 | }
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Server/VoiceServer.Events.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceServer.Events.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using JustAnotherVoiceChat.Server.Wrapper.Delegates;
30 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
31 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
32 |
33 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Server
34 | {
35 | public partial class VoiceServer where TClient : IVoiceClient
36 | {
37 | public event Delegates.EmptyEvent OnServerStarted;
38 | public event Delegates.EmptyEvent OnServerStopping;
39 |
40 | public event Delegates.ClientEvent OnClientConnected;
41 | public event Delegates.ClientConnectingEvent OnClientConnecting;
42 | public event Delegates.ClientRejectedEvent OnClientRejected;
43 | public event Delegates.ClientEvent OnClientDisconnected;
44 |
45 | public event Delegates.ClientStatusEvent OnClientTalkingChanged;
46 | public event Delegates.ClientMuteStatusEvent OnClientSpeakersMuteChanged;
47 | public event Delegates.ClientMuteStatusEvent OnClientMicrophoneMuteChanged;
48 |
49 | public event Delegates.LogMessageEvent OnLogMessage;
50 |
51 | private void DisposeEvents()
52 | {
53 | OnServerStarted = null;
54 | OnServerStopping = null;
55 |
56 | OnClientConnected = null;
57 | OnClientConnecting = null;
58 | OnClientDisconnected = null;
59 | OnClientRejected = null;
60 |
61 | OnClientTalkingChanged = null;
62 | OnClientSpeakersMuteChanged = null;
63 | OnClientMicrophoneMuteChanged = null;
64 |
65 | OnLogMessage = null;
66 |
67 | DisposeNativeEvents();
68 | }
69 |
70 | internal void InvokeProtectedEvent(Action callback)
71 | {
72 | try
73 | {
74 | callback();
75 | }
76 | catch (Exception e)
77 | {
78 | Log(LogLevel.Error, $"An error occured inside eventhandler: {e}");
79 | }
80 | }
81 |
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Server/VoiceServer.Positional.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceServer.Positional.cs
3 | * Date: 27.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Collections.Generic;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
31 |
32 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Server
33 | {
34 | public partial class VoiceServer where TClient : IVoiceClient
35 | {
36 |
37 | public bool SetPlayerPositions(IEnumerable clientPositions)
38 | {
39 | return NativeWrapper.SetListenerPositions(clientPositions);
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Server/VoiceServer.Tasks.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceServer.Tasks.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using System.Collections.Concurrent;
30 | using System.Collections.Generic;
31 | using System.Threading;
32 | using System.Threading.Tasks;
33 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Server.Helpers;
34 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
35 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
36 |
37 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Server
38 | {
39 | public partial class VoiceServer where TClient : IVoiceClient
40 | {
41 | private readonly ConcurrentBag _voiceTasks = new ConcurrentBag();
42 |
43 | private void AttachTasksToStartAndStopEvent()
44 | {
45 | OnServerStarted += StartTasks;
46 | OnServerStopping += StopTasks;
47 | }
48 |
49 | private void StartTasks()
50 | {
51 | foreach (var task in _voiceTasks)
52 | {
53 | task.Start();
54 | }
55 | }
56 |
57 | private void StopTasks()
58 | {
59 | foreach (var task in _voiceTasks)
60 | {
61 | task.Stop();
62 | }
63 | }
64 |
65 | public void AddTask(IVoiceTask voiceTask)
66 | {
67 | if (voiceTask == null)
68 | {
69 | throw new ArgumentNullException(nameof(voiceTask));
70 | }
71 |
72 | var executor = new VoiceTaskExecutor(voiceTask, this);
73 |
74 | _voiceTasks.Add(executor);
75 |
76 | if (Started)
77 | {
78 | executor.Start();
79 | }
80 | }
81 |
82 | public void AddTasks(IEnumerable> voiceTasks)
83 | {
84 | foreach (var voiceTask in voiceTasks)
85 | {
86 | AddTask(voiceTask);
87 | }
88 | }
89 |
90 | private void DisposeTasks()
91 | {
92 | foreach (var voiceTask in _voiceTasks)
93 | {
94 | voiceTask.Dispose();
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Tasks/PositionalVoiceTask.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: PositionalVoiceTask.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Linq;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Tasks
32 | {
33 | public class PositionalVoiceTask : IVoiceTask where TClient : IVoiceClient
34 | {
35 | private readonly int _sleepTime;
36 |
37 | public PositionalVoiceTask(int sleepTime = 125)
38 | {
39 | _sleepTime = sleepTime;
40 | }
41 |
42 | public virtual int RunVoiceTask(IVoiceServer server)
43 | {
44 | var clientPositions = server.GetClients().Select(client => client.MakeClientPosition());
45 |
46 | server.SetPlayerPositions(clientPositions);
47 |
48 | return _sleepTime;
49 | }
50 |
51 | public virtual void Dispose()
52 | {
53 |
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Wrapper/VoiceWrapper.Clients.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceWrapper.Clients.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Wrapper
31 | {
32 | internal partial class VoiceWrapper
33 | {
34 | public bool RemoveClient(IVoiceClient client)
35 | {
36 | return NativeLibary.JV_RemoveClient(client.Handle.Identifer);
37 | }
38 |
39 | public bool SetClientNickname(IVoiceClient client, string nickname)
40 | {
41 | return NativeLibary.JV_SetClientNickname(client.Handle.Identifer, nickname);
42 | }
43 |
44 | public bool SetClientVoiceRange(IVoiceClient client, float voiceRange)
45 | {
46 | return NativeLibary.JV_SetClientVoiceRange(client.Handle.Identifer, voiceRange);
47 | }
48 |
49 | public bool IsClientConnected(IVoiceClient client)
50 | {
51 | return NativeLibary.JV_IsClientConnected(client.Handle.Identifer);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Wrapper/VoiceWrapper.Muting.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceWrapper.Muting.cs
3 | * Date: 25.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Wrapper
31 | {
32 | internal partial class VoiceWrapper
33 | {
34 | public bool MuteClientForAll(IVoiceClient client, bool muted)
35 | {
36 | return NativeLibary.JV_MuteClientForAll(client.Handle.Identifer, muted);
37 | }
38 |
39 | public bool IsClientMutedForAll(IVoiceClient client)
40 | {
41 | return NativeLibary.JV_IsClientMutedForAll(client.Handle.Identifer);
42 | }
43 |
44 | public bool MuteClientForClient(IVoiceClient speaker, IVoiceClient listener, bool muted)
45 | {
46 | return NativeLibary.JV_MuteClientForClient(speaker.Handle.Identifer, listener.Handle.Identifer, muted);
47 | }
48 |
49 | public bool IsClientMutedForClient(IVoiceClient speaker, IVoiceClient listener)
50 | {
51 | return NativeLibary.JV_IsClientMutedForClient(speaker.Handle.Identifer, listener.Handle.Identifer);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Wrapper/VoiceWrapper.Positional.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceWrapper.Positional.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Collections.Generic;
29 | using System.Linq;
30 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
31 | using JustAnotherVoiceChat.Server.Wrapper.Math;
32 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
33 |
34 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Wrapper
35 | {
36 | internal partial class VoiceWrapper
37 | {
38 |
39 | public bool ResetAllRelativePositionsForListener(IVoiceClient listener)
40 | {
41 | return NativeLibary.JV_ResetAllRelativePositions(listener.Handle.Identifer);
42 | }
43 |
44 | public bool ResetRelativeSpeakerPositionForListener(IVoiceClient listener, IVoiceClient speaker)
45 | {
46 | return NativeLibary.JV_ResetRelativePositionForClient(listener.Handle.Identifer, speaker.Handle.Identifer);
47 | }
48 |
49 | public bool SetListenerPosition(IVoiceClient listener, Vector3 position, float rotation)
50 | {
51 | return SetListenerPositions(new [] { listener.MakeClientPosition(position, rotation) });
52 | }
53 |
54 | public bool SetListenerPositions(IEnumerable clientPositions)
55 | {
56 | var positions = clientPositions.ToArray();
57 | return NativeLibary.JV_SetClientPositions(positions, positions.Length);
58 | }
59 |
60 | public bool SetRelativeSpeakerPositionForListener(IVoiceClient listener, IVoiceClient speaker, Vector3 position)
61 | {
62 | return NativeLibary.JV_SetRelativePositionForClient(listener.Handle.Identifer, speaker.Handle.Identifer, position.X, position.Y, position.Z);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Elements/Wrapper/VoiceWrapper.Server.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceWrapper.Server.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Security;
29 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
30 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
31 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
32 |
33 | namespace JustAnotherVoiceChat.Server.Wrapper.Elements.Wrapper
34 | {
35 | [SecurityCritical]
36 | internal partial class VoiceWrapper : IVoiceWrapper
37 | {
38 | public void CreateNativeServer(VoiceServerConfiguration configuration)
39 | {
40 | NativeLibary.JV_CreateServer(configuration.Port, configuration.TeamspeakServerId, configuration.TeamspeakChannelId, configuration.TeamspeakChannelPassword);
41 | }
42 |
43 | public void DestroyNativeServer()
44 | {
45 | NativeLibary.JV_DestroyServer();
46 | }
47 |
48 | public bool StartNativeServer()
49 | {
50 | return NativeLibary.JV_StartServer();
51 | }
52 |
53 | public void StopNativeServer()
54 | {
55 | NativeLibary.JV_StopServer();
56 | }
57 |
58 | public void Set3DSettings(float distanceFactor, float rolloffFactor)
59 | {
60 | NativeLibary.JV_Set3DSettings(distanceFactor, rolloffFactor);
61 | }
62 |
63 | public void SetLogLevel(LogLevel logLevel)
64 | {
65 | NativeLibary.JV_SetLogLevel((int) logLevel);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Enums/LogLevel.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: LogLevel.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | namespace JustAnotherVoiceChat.Server.Wrapper.Enums
29 | {
30 | public enum LogLevel
31 | {
32 | Error,
33 | Warning,
34 | Info,
35 | Debug,
36 | Trace
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Enums/StatusCode.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: StatusCode.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | namespace JustAnotherVoiceChat.Server.Wrapper.Enums
29 | {
30 | public enum StatusCode
31 | {
32 | Ok,
33 | UnknownError,
34 | NotConnectedToServer,
35 | NotMovedToChannel,
36 | UnableToMuteClients,
37 | OutdatedProtocolVersion
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Exceptions/ClientNotConnectedException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ClientNotConnectedException.cs
3 | * Date: 28.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper.Exceptions
32 | {
33 | public class ClientNotConnectedException : Exception
34 | {
35 | public ClientNotConnectedException(VoiceHandle clientVoiceHandle) : base($"Client not connected to native server! Identifier: {clientVoiceHandle.Identifer}")
36 | {
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Exceptions/InvalidClientException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: InvalidClientException.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper.Exceptions
32 | {
33 | public class InvalidClientException : Exception
34 | {
35 |
36 | public InvalidClientException() : base("The provided voiceclient doesn't exist")
37 | {
38 |
39 | }
40 |
41 | public InvalidClientException(ushort handle) : base($"The provided client (UID {handle}) doesn't exist")
42 | {
43 |
44 | }
45 |
46 | public InvalidClientException(VoiceHandle handle) : this(handle.Identifer)
47 | {
48 |
49 | }
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Exceptions/VoiceServerAlreadyStartedException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceServerAlreadyStartedException.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Exceptions
31 | {
32 | public class VoiceServerAlreadyStartedException : Exception
33 | {
34 |
35 | public VoiceServerAlreadyStartedException() : base("The JustAnotherVoiceChat Server was already started!")
36 | {
37 |
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Exceptions/VoiceServerNotStartedException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceServerNotStartedException.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Exceptions
31 | {
32 | public class VoiceServerNotStartedException : Exception
33 | {
34 |
35 | public VoiceServerNotStartedException() : base("The JustAnotherVoiceChat Server has not been started yet")
36 | {
37 |
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Interfaces/IVoiceClient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IVoiceClient.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using System.Collections.Generic;
30 | using JustAnotherVoiceChat.Server.Wrapper.Math;
31 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
32 |
33 | namespace JustAnotherVoiceChat.Server.Wrapper.Interfaces
34 | {
35 | public interface IVoiceClient : IDisposable
36 | {
37 |
38 | VoiceHandle Handle { get; }
39 |
40 | bool Connected { get; }
41 |
42 | bool Microphone { get; }
43 |
44 | bool Speakers { get; }
45 |
46 | Vector3 Position { get; }
47 | float CameraRotation { get; set; }
48 |
49 | string HandshakeUrl { get; }
50 |
51 | bool SetNickname(string nickname);
52 | bool SetVoiceRange(float range);
53 |
54 | bool SetListeningPosition(Vector3 position, float rotation);
55 | bool SetRelativeSpeakerPosition(IVoiceClient speaker, Vector3 position);
56 | bool ResetRelativeSpeakerPosition(IVoiceClient speaker);
57 | bool ResetAllRelativeSpeakerPositions();
58 |
59 | bool MuteForAll(bool muted);
60 | bool IsMutedForAll();
61 | bool MuteSpeaker(IVoiceClient speaker, bool muted);
62 | bool IsSpeakerMuted(IVoiceClient speaker);
63 |
64 | ClientPosition MakeClientPosition(Vector3 position, float rotation);
65 | ClientPosition MakeClientPosition();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Interfaces/IVoiceClientFactory.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IVoiceClientFactory.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Interfaces
31 | {
32 | public interface IVoiceClientFactory where TClient : IVoiceClient
33 | {
34 |
35 | TClient MakeClient(TIdentifier identifier, IVoiceServer server, VoiceHandle handle);
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Interfaces/IVoiceServer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IVoiceServer.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 | using System.Collections.Generic;
30 | using JustAnotherVoiceChat.Server.Wrapper.Delegates;
31 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
32 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
33 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
34 |
35 | namespace JustAnotherVoiceChat.Server.Wrapper.Interfaces
36 | {
37 | public interface IVoiceServer : IDisposable where TClient : IVoiceClient
38 | {
39 | event Delegates.EmptyEvent OnServerStarted;
40 | event Delegates.EmptyEvent OnServerStopping;
41 |
42 | event Delegates.ClientEvent OnClientConnected;
43 | event Delegates.ClientConnectingEvent OnClientConnecting;
44 | event Delegates.ClientRejectedEvent OnClientRejected;
45 | event Delegates.ClientEvent OnClientDisconnected;
46 |
47 | event Delegates.ClientStatusEvent OnClientTalkingChanged;
48 | event Delegates.ClientMuteStatusEvent OnClientMicrophoneMuteChanged;
49 | event Delegates.ClientMuteStatusEvent OnClientSpeakersMuteChanged;
50 | event Delegates.LogMessageEvent OnLogMessage;
51 |
52 | bool Started { get; }
53 |
54 | VoiceServerConfiguration Configuration { get; }
55 | IVoiceWrapper NativeWrapper { get; }
56 |
57 | void Start();
58 | void Stop();
59 |
60 | void Log(LogLevel logLevel, string message);
61 | void Log(string message);
62 | void SetLogLevel(LogLevel logLevel);
63 |
64 | TClient GetVoiceClient(VoiceHandle handle);
65 | TClient GetVoiceClient(ushort handle);
66 |
67 | TClient FindClient(Func filter);
68 |
69 | IEnumerable GetClients(Func filter);
70 | IEnumerable GetClients();
71 |
72 | void AddTask(IVoiceTask voiceTask);
73 | void AddTasks(IEnumerable> voiceTasks);
74 |
75 | bool SetPlayerPositions(IEnumerable clientPositions);
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Interfaces/IVoiceTask.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IVoiceTask.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Interfaces
31 | {
32 | public interface IVoiceTask : IDisposable where TClient : IVoiceClient
33 | {
34 | int RunVoiceTask(IVoiceServer server);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Interfaces/IVoiceTaskExecutor.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IVoiceTaskExecutor.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Interfaces
31 | {
32 | internal interface IVoiceTaskExecutor : IDisposable
33 | {
34 |
35 | void Start();
36 | void Stop();
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Interfaces/IVoiceWrapper.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: IVoiceWrapper.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Collections.Generic;
29 | using JustAnotherVoiceChat.Server.Wrapper.Delegates;
30 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Models;
31 | using JustAnotherVoiceChat.Server.Wrapper.Enums;
32 | using JustAnotherVoiceChat.Server.Wrapper.Math;
33 | using JustAnotherVoiceChat.Server.Wrapper.Structs;
34 |
35 | namespace JustAnotherVoiceChat.Server.Wrapper.Interfaces
36 | {
37 | public interface IVoiceWrapper
38 | {
39 | void CreateNativeServer(VoiceServerConfiguration configuration);
40 | void DestroyNativeServer();
41 | bool StartNativeServer();
42 | void StopNativeServer();
43 |
44 | bool RemoveClient(IVoiceClient client);
45 | bool SetClientNickname(IVoiceClient client, string nickname);
46 | bool IsClientConnected(IVoiceClient client);
47 |
48 | void Set3DSettings(float distanceFactor, float rolloffFactor);
49 | void SetLogLevel(LogLevel logLevel);
50 |
51 | void UnregisterClientConnectedCallback();
52 | void UnregisterClientConnectingCallback();
53 | void UnregisterClientDisconnectedCallback();
54 | void UnregisterClientRejectedCallback();
55 |
56 | void UnregisterClientTalkingChangedCallback();
57 | void UnregisterClientSpeakersMuteChangedCallback();
58 | void UnregisterClientMicrophoneMuteChangedCallback();
59 | void UnregisterLogMessageCallback();
60 |
61 | void RegisterClientConnectingCallback(NativeDelegates.ClientConnectingCallback callback);
62 | void RegisterClientConnectedCallback(NativeDelegates.ClientCallback callback);
63 | void RegisterClientRejectedCallback(NativeDelegates.ClientRejectedCallback callback);
64 | void RegisterClientDisconnectedCallback(NativeDelegates.ClientCallback callback);
65 |
66 | void RegisterClientTalkingChangedCallback(NativeDelegates.ClientStatusCallback callback);
67 | void RegisterClientSpeakersMuteChangedCallback(NativeDelegates.ClientStatusCallback callback);
68 | void RegisterClientMicrophoneMuteChangedCallback(NativeDelegates.ClientStatusCallback callback);
69 |
70 | void RegisterLogMessageCallback(NativeDelegates.LogMessageCallback callback);
71 |
72 | bool SetClientVoiceRange(IVoiceClient client, float voiceRange);
73 | bool SetListenerPosition(IVoiceClient listener, Vector3 position, float rotation);
74 | bool SetListenerPositions(IEnumerable clientPositions);
75 | bool SetRelativeSpeakerPositionForListener(IVoiceClient listener, IVoiceClient speaker, Vector3 position);
76 | bool ResetRelativeSpeakerPositionForListener(IVoiceClient listener, IVoiceClient speaker);
77 | bool ResetAllRelativePositionsForListener(IVoiceClient listener);
78 |
79 | bool MuteClientForAll(IVoiceClient client, bool muted);
80 | bool IsClientMutedForAll(IVoiceClient client);
81 | bool MuteClientForClient(IVoiceClient speaker, IVoiceClient listener, bool muted);
82 | bool IsClientMutedForClient(IVoiceClient speaker, IVoiceClient listener);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/JustAnotherVoiceChat.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: JustAnotherVoiceChat.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using JustAnotherVoiceChat.Server.Wrapper.Elements.Wrapper;
29 | using JustAnotherVoiceChat.Server.Wrapper.Interfaces;
30 |
31 | namespace JustAnotherVoiceChat.Server.Wrapper
32 | {
33 | internal static class JustAnotherVoiceChat
34 | {
35 | private static IVoiceWrapper _voiceWrapper;
36 |
37 | internal static IVoiceWrapper GetVoiceWrapper()
38 | {
39 | if(_voiceWrapper == null)
40 | {
41 | _voiceWrapper = new VoiceWrapper();
42 | }
43 |
44 | return _voiceWrapper;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Structs/ClientPosition.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: ClientPosition.cs
3 | * Date: 27.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | using System.Runtime.InteropServices;
29 |
30 | namespace JustAnotherVoiceChat.Server.Wrapper.Structs
31 | {
32 | [StructLayout(LayoutKind.Sequential)]
33 | public struct ClientPosition
34 | {
35 |
36 | public float PositionX { get; }
37 | public float PositionY { get; }
38 | public float PositionZ { get; }
39 |
40 | public float Rotation { get; }
41 |
42 | public ushort Handle { get; }
43 |
44 | internal ClientPosition(ushort handle, float positionX, float positionY, float positionZ, float rotation)
45 | {
46 | PositionX = positionX;
47 | PositionY = positionY;
48 | PositionZ = positionZ;
49 | Rotation = rotation;
50 | Handle = handle;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.Wrapper/src/Structs/VoiceHandle.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * File: VoiceHandle.cs
3 | * Date: 21.2.2018,
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | namespace JustAnotherVoiceChat.Server.Wrapper.Structs
29 | {
30 | public struct VoiceHandle
31 | {
32 | public static VoiceHandle Empty => new VoiceHandle(0);
33 |
34 | public bool IsEmpty => Identifer == 0;
35 | public ushort Identifer { get; }
36 |
37 | public VoiceHandle(ushort identifer)
38 | {
39 | Identifer = identifer;
40 | }
41 |
42 | public bool Equals(VoiceHandle other)
43 | {
44 | return Identifer == other.Identifer;
45 | }
46 |
47 | public override bool Equals(object obj)
48 | {
49 | if (ReferenceEquals(null, obj)) return false;
50 | return obj is VoiceHandle && Equals((VoiceHandle) obj);
51 | }
52 |
53 | public override int GetHashCode()
54 | {
55 | return Identifer.GetHashCode();
56 | }
57 |
58 | public static bool operator ==(VoiceHandle left, VoiceHandle right)
59 | {
60 | return left.Equals(right);
61 | }
62 |
63 | public static bool operator !=(VoiceHandle left, VoiceHandle right)
64 | {
65 | return !left.Equals(right);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server.sln.licenseheader:
--------------------------------------------------------------------------------
1 | extensions: .cs .js
2 | /*
3 | * File: %FileName%
4 | * Date: %CreationDay%.%CreationMonth%.%CreationYear%,
5 | *
6 | * MIT License
7 | *
8 | * Copyright (c) 2018 JustAnotherVoiceChat
9 | *
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * of this software and associated documentation files (the "Software"), to deal
12 | * in the Software without restriction, including without limitation the rights
13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * copies of the Software, and to permit persons to whom the Software is
15 | * furnished to do so, subject to the following conditions:
16 | *
17 | * The above copyright notice and this permission notice shall be included in all
18 | * copies or substantial portions of the Software.
19 | *
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * SOFTWARE.
27 | */
28 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Setup base project
2 | cmake_minimum_required(VERSION 3.5)
3 | project(JustAnotherVoiceChat VERSION 0.3.4 LANGUAGES CXX)
4 |
5 | # Make sure to install libraries into correct locations
6 | include(GNUInstallDirs)
7 |
8 | # Setup basic C++ and project attributes
9 | set(CMAKE_CXX_STANDARD 11)
10 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
11 |
12 | if (MSVC)
13 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
14 | else()
15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
16 | endif()
17 |
18 | set(CMAKE_POSITION_INDEPENDENT_CODE ON)
19 |
20 | if(WIN32)
21 | add_definitions(-DNOMINMAX /wd4251)
22 | endif(WIN32)
23 |
24 | include_directories(include)
25 | include_directories(thirdparty/enet/include)
26 | include_directories(thirdparty/cereal/include)
27 | include_directories(thirdparty/linalg)
28 |
29 | # Add targets
30 | enable_testing()
31 |
32 | add_subdirectory(src)
33 | add_subdirectory(tests)
34 |
35 | # Add dependencies
36 | if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
37 | set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings")
38 | endif()
39 |
40 | add_subdirectory(thirdparty/enet)
41 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/include/internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: include/internal.h
3 | * Date: 29.01.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #pragma once
29 |
30 | bool initialize();
31 |
32 | void deinitialize();
33 |
34 | bool isInitialized();
35 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/include/justAnotherVoiceChat.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: include/justAnotherVoiceChat.h
3 | * Date: 25.01.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #pragma once
29 |
30 | #ifdef _WIN32
31 | #ifdef JUSTANOTHERVOICECHAT_EXPORTS
32 | #define JUSTANOTHERVOICECHAT_API __declspec(dllexport)
33 | #else
34 | #define JUSTANOTHERVOICECHAT_API __declspec(dllimport)
35 | #endif
36 | #else
37 | #define JUSTANOTHERVOICECHAT_API
38 | #endif
39 |
40 | #include
41 |
42 | // global typedefs
43 | typedef struct {
44 | float x;
45 | float y;
46 | float z;
47 | float rotation;
48 | uint16_t gameId;
49 | } clientPosition_t;
50 |
51 | // C++ public classes
52 | #include "server.h"
53 | #include "client.h"
54 | #include "log.h"
55 |
56 | // C wrapped API
57 | #include "api.h"
58 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/include/log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: include/log.h
3 | * Date: 17.02.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | #define LOG_LEVEL_ERROR 0
33 | #define LOG_LEVEL_WARNING 1
34 | #define LOG_LEVEL_INFO 2
35 | #define LOG_LEVEL_DEBUG 3
36 | #define LOG_LEVEL_TRACE 4
37 |
38 | typedef void (* logMessageCallback_t)(const char *, int level);
39 |
40 | void setLogLevel(int logLevel);
41 |
42 | void logMessage(std::string message, int level = LOG_LEVEL_INFO);
43 |
44 | void setLogMessageCallback(logMessageCallback_t callback);
45 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Setup library project
2 | add_definitions(-DJUSTANOTHERVOICECHAT_EXPORTS)
3 |
4 | # Search required libraries
5 | find_package(Threads)
6 |
7 | # Add files to library
8 | file(GLOB SOURCES "./*.cpp")
9 |
10 | add_library(JustAnotherVoiceChat.Server SHARED ${SOURCES})
11 |
12 | # Link required libraries
13 | target_link_libraries(JustAnotherVoiceChat.Server enet)
14 |
15 | target_link_libraries(JustAnotherVoiceChat.Server ${CMAKE_THREAD_LIBS_INIT})
16 |
17 | if(WIN32)
18 | target_link_libraries(JustAnotherVoiceChat.Server ws2_32)
19 | target_link_libraries(JustAnotherVoiceChat.Server winmm)
20 | endif(WIN32)
21 |
22 | # Setup install directories
23 | install(TARGETS JustAnotherVoiceChat.Server ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
24 | install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/JustAnotherVoiceChat)
25 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/src/internal.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: src/internal.cpp
3 | * Date: 29.01.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #include "internal.h"
29 |
30 | #include
31 |
32 | #ifdef _WIN32
33 | #include
34 | #endif
35 |
36 | bool _isInitialized = false;
37 |
38 | bool initialize() {
39 | if (_isInitialized) {
40 | return true;
41 | }
42 |
43 | if (enet_initialize() != 0) {
44 | return false;
45 | }
46 |
47 | _isInitialized = true;
48 |
49 | return true;
50 | }
51 |
52 | void deinitialize() {
53 | if (_isInitialized) {
54 | enet_deinitialize();
55 |
56 | _isInitialized = false;
57 | }
58 | }
59 |
60 | bool isInitialized() {
61 | return _isInitialized;
62 | }
63 |
64 | #ifdef _WIN32
65 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdReason, LPVOID lpvReserved) {
66 | switch (fwdReason) {
67 | case DLL_PROCESS_ATTACH:
68 |
69 | break;
70 |
71 | case DLL_PROCESS_DETACH:
72 |
73 | break;
74 |
75 | case DLL_THREAD_ATTACH:
76 |
77 | break;
78 |
79 | case DLL_THREAD_DETACH:
80 |
81 | break;
82 | }
83 |
84 | return TRUE;
85 | }
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/src/log.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: src/log.cpp
3 | * Date: 17.02.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #include "log.h"
29 |
30 | static logMessageCallback_t _logMessageCallback = nullptr;
31 |
32 | int _logLevel = LOG_LEVEL_INFO;
33 |
34 | void setLogLevel(int logLevel) {
35 | _logLevel = logLevel;
36 |
37 | if (_logLevel > LOG_LEVEL_TRACE) {
38 | _logLevel = LOG_LEVEL_TRACE;
39 | } else if (_logLevel < LOG_LEVEL_ERROR) {
40 | _logLevel = LOG_LEVEL_ERROR;
41 | }
42 | }
43 |
44 | void logMessage(std::string message, int level) {
45 | if (_logMessageCallback == nullptr) {
46 | return;
47 | }
48 |
49 | if (level > _logLevel) {
50 | return;
51 | }
52 |
53 | _logMessageCallback(message.c_str(), level);
54 | }
55 |
56 | void setLogMessageCallback(logMessageCallback_t callback) {
57 | _logMessageCallback = callback;
58 | }
59 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Setup test project
2 | file(GLOB SOURCES "./*.cpp")
3 |
4 | # Add executable
5 | add_executable(JustAnotherVoiceChatTest ${SOURCES})
6 |
7 | # Link library to test
8 | target_link_libraries(JustAnotherVoiceChatTest JustAnotherVoiceChat.Server)
9 |
10 | add_dependencies(JustAnotherVoiceChatTest JustAnotherVoiceChat.Server)
11 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/tests/test.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: tests/test.cpp
3 | * Date: 29.01.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #include
29 | #include
30 |
31 | #ifdef _WIN32
32 |
33 | #else
34 | #include
35 | #endif
36 |
37 | #include "justAnotherVoiceChat.h"
38 | #include "testClient.h"
39 |
40 | #include "../thirdparty/JustAnotherVoiceChat/include/protocol.h"
41 |
42 | #include "test_api.h"
43 |
44 | void clientConnectedCallback(uint16_t clientId) {
45 | std::cout << "[TEST] Client connected " << clientId << std::endl;
46 | }
47 |
48 | void clientTalkingChangedCallback(uint16_t clientId, bool talking) {
49 | std::cout << "[TEST] Client " << clientId << " changed talking " << talking << std::endl;
50 | }
51 |
52 | void clientMicrophoneMuteChangedCallback(uint16_t clientId, bool muted) {
53 | std::cout << "[TEST] Client " << clientId << " changed microphone mute to " << muted << std::endl;
54 | }
55 |
56 | void clientSpeakersMuteChangedCallback(uint16_t clientId, bool muted) {
57 | std::cout << "[TEST] Client " << clientId << " changed speakers mute to " << muted << std::endl;
58 | }
59 |
60 | void logMessage(const char *message, int level) {
61 | std::string levelString = "";
62 |
63 | switch (level) {
64 | case LOG_LEVEL_ERROR:
65 | levelString = "ERROR";
66 | break;
67 |
68 | case LOG_LEVEL_WARNING:
69 | levelString = "WARNING";
70 | break;
71 |
72 | case LOG_LEVEL_INFO:
73 | levelString = "INFO";
74 | break;
75 |
76 | case LOG_LEVEL_DEBUG:
77 | levelString = "DEBUG";
78 | break;
79 | }
80 |
81 | std::cout << "[" << levelString << "] " << message << std::endl;
82 | }
83 |
84 | #ifdef _WIN32
85 |
86 | #else
87 | void signalHandler(int signum) {
88 | JV_StopServer();
89 | }
90 | #endif
91 |
92 | int main() {
93 | test_api();
94 |
95 | #ifdef _WIN32
96 |
97 | #else
98 | signal(SIGTERM, signalHandler);
99 | signal(SIGINT, signalHandler);
100 | #endif
101 |
102 | // create server
103 | JV_CreateServer(ENET_PORT, "", 0, "");
104 | JV_RegisterLogMessageCallback(logMessage);
105 |
106 | if (JV_StartServer() == false) {
107 | std::cerr << "[TEST] Unable to create JustAnotherVoiceChat server on port " << ENET_PORT << std::endl;
108 | return EXIT_FAILURE;
109 | }
110 |
111 | JV_RegisterClientConnectedCallback(clientConnectedCallback);
112 | JV_RegisterClientTalkingChangedCallback(clientTalkingChangedCallback);
113 | JV_RegisterClientMicrophoneMuteChangedCallback(clientMicrophoneMuteChangedCallback);
114 | JV_RegisterClientSpeakersMuteChangedCallback(clientSpeakersMuteChangedCallback);
115 |
116 | std::cout << "[TEST] JustAnotherVoiceChat server created on port " << ENET_PORT << std::endl;
117 |
118 | auto client = new TestClient(123, 456);
119 | if (client->connect("localhost", ENET_PORT) == false) {
120 | std::cout << "[TEST] Connection to localhost:" << ENET_PORT << " failed" << std::endl;
121 | return EXIT_FAILURE;
122 | }
123 |
124 | std::cout << "[TEST] Connection established" << std::endl;
125 |
126 | // main loop
127 | while (JV_IsServerRunning()) {
128 | client->update();
129 | }
130 |
131 | std::cout << "[TEST] Stopping JustAnotherVoiceChat server..." << std::endl;
132 |
133 | // clean up
134 | delete client;
135 |
136 | JV_StopServer();
137 |
138 | std::cout << "[TEST] Stopped JustAnotherVoiceChat server..." << std::endl;
139 |
140 | return EXIT_SUCCESS;
141 | }
142 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/tests/testClient.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: tests/testClient.cpp
3 | * Date: 09.02.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #include "testClient.h"
29 |
30 | #include "../thirdparty/JustAnotherVoiceChat/include/protocol.h"
31 |
32 | TestClient::TestClient(uint16_t gameId, uint16_t teamspeakId) {
33 | _client = nullptr;
34 | _peer = nullptr;
35 | _gameId = gameId;
36 | _teamspeakId = teamspeakId;
37 | }
38 |
39 | TestClient::~TestClient() {
40 | if (_peer != nullptr) {
41 | enet_peer_reset(_peer);
42 | }
43 |
44 | if (_client != nullptr) {
45 | enet_host_destroy(_client);
46 | }
47 | }
48 |
49 | bool TestClient::connect(std::string host, uint16_t port) {
50 | // create host
51 | _client = enet_host_create(NULL, 1, NETWORK_CHANNELS, 0, 0);
52 | if (_client == NULL) {
53 | _client = nullptr;
54 | return false;
55 | }
56 |
57 | ENetAddress address;
58 | enet_address_set_host(&address, host.c_str());
59 | address.port = port;
60 |
61 | // connect
62 | _peer = enet_host_connect(_client, &address, NETWORK_CHANNELS, 0);
63 | if (_peer == NULL) {
64 | _peer = nullptr;
65 | return false;
66 | }
67 |
68 | return true;
69 | }
70 |
71 | void TestClient::disconnect() {
72 | enet_peer_disconnect(_peer, 0);
73 | }
74 |
75 | bool TestClient::isConnected() const {
76 | return _client != nullptr && _peer != nullptr;
77 | }
78 |
79 | void TestClient::sendHandshake(uint16_t gameId, uint16_t teamspeakId) {
80 | handshakePacket_t packet;
81 | packet.gameId = gameId;
82 | packet.teamspeakId = teamspeakId;
83 |
84 | std::ostringstream os;
85 | {
86 | cereal::BinaryOutputArchive archive(os);
87 | archive(packet);
88 | }
89 |
90 | auto data = os.str();
91 | sendPacket((void *)data.c_str(), data.size(), NETWORK_HANDSHAKE_CHANNEL);
92 | }
93 |
94 | void TestClient::update() {
95 | ENetEvent event;
96 |
97 | if (enet_host_service(_client, &event, 100) > 0) {
98 | switch (event.type) {
99 | case ENET_EVENT_TYPE_CONNECT:
100 | sendHandshake(_gameId, _teamspeakId);
101 | break;
102 |
103 | case ENET_EVENT_TYPE_DISCONNECT:
104 |
105 | break;
106 |
107 | case ENET_EVENT_TYPE_RECEIVE:
108 |
109 | break;
110 |
111 | default:
112 |
113 | break;
114 | }
115 | }
116 | }
117 |
118 | void TestClient::sendPacket(void *data, size_t length, int channel, bool reliable) {
119 | enet_uint32 flags = 0;
120 |
121 | if (reliable) {
122 | flags |= ENET_PACKET_FLAG_RELIABLE;
123 | }
124 |
125 | ENetPacket *packet = enet_packet_create(data, length, flags);
126 | enet_peer_send(_peer, channel, packet);
127 | }
128 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/tests/testClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: tests/testClient.h
3 | * Date: 09.02.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | class TestClient {
34 | private:
35 | ENetHost *_client;
36 | ENetPeer *_peer;
37 |
38 | uint16_t _gameId;
39 | uint16_t _teamspeakId;
40 |
41 | public:
42 | TestClient(uint16_t gameId, uint16_t teamspeakId);
43 | virtual ~TestClient();
44 |
45 | bool connect(std::string host, uint16_t port);
46 | void disconnect();
47 | bool isConnected() const;
48 |
49 | void sendHandshake(uint16_t gameId, uint16_t teamspeakId);
50 |
51 | void update();
52 |
53 | private:
54 | void sendPacket(void *data, size_t length, int channel, bool reliable = true);
55 | };
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/tests/test_api.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * File: tests/test_api.cpp
3 | * Date: 09.02.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #include "test_api.h"
29 |
30 | #include "api.h"
31 |
32 | #include "../thirdparty/JustAnotherVoiceChat/include/protocol.h"
33 |
34 | void test_api() {
35 | // test if methods exists
36 | JV_RegisterLogMessageCallback(NULL);
37 | JV_CreateServer(ENET_PORT, "", 0, "");
38 | JV_StartServer();
39 | JV_IsServerRunning();
40 | JV_StopServer();
41 | JV_RegisterClientConnectedCallback(NULL);
42 | JV_UnregisterClientConnectedCallback();
43 | JV_RegisterClientDisconnectedCallback(NULL);
44 | JV_UnregisterClientDisconnectedCallback();
45 | JV_RegisterClientMicrophoneMuteChangedCallback(NULL);
46 | JV_UnregisterClientMicrophoneMuteChangedCallback();
47 | JV_RegisterClientSpeakersMuteChangedCallback(NULL);
48 | JV_UnregisterClientSpeakersMuteChangedCallback();
49 | JV_RegisterClientTalkingChangedCallback(NULL);
50 | JV_UnregisterClientTalkingChangedCallback();
51 | JV_GetNumberOfClients();
52 | JV_GetClientGameIds(NULL, 0);
53 | JV_RemoveClient(0);
54 | JV_RemoveAllClients();
55 | JV_SetClientPosition(0, 0, 0, 0, 0);
56 | JV_Set3DSettings(0, 0);
57 | JV_SetRelativePositionForClient(0, 0, 0, 0, 0);
58 | JV_ResetRelativePositionForClient(0, 0);
59 | JV_ResetAllRelativePositions(0);
60 | }
61 |
--------------------------------------------------------------------------------
/JustAnotherVoiceChat.Server/tests/test_api.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: tests/test_api.h
3 | * Date: 29.01.2018
4 | *
5 | * MIT License
6 | *
7 | * Copyright (c) 2018 JustAnotherVoiceChat
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in all
17 | * copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | * SOFTWARE.
26 | */
27 |
28 | #pragma once
29 |
30 | void test_api();
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 JustAnotherVoiceChat
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | os: Visual Studio 2017
2 | version: 0.3.4.{build}
3 |
4 | skip_branch_with_pr: true
5 |
6 | dotnet_csproj:
7 | patch: true
8 | file: 'JustAnotherVoiceChat.Server.Wrapper\*.csproj'
9 | version: '{version}'
10 | assembly_version: '{version}'
11 | file_version: '{version}'
12 |
13 | assembly_info:
14 | patch: true
15 | file: 'JustAnotherVoiceChat.Server.GTMP\Properties\AssemblyInfo.cs'
16 | assembly_version: '{version}'
17 | assembly_file_version: '{version}'
18 |
19 | artifacts:
20 | - path: '**\JustAnotherVoiceChat*.nupkg'
21 | name: NuGet Packages
22 |
23 | - path: 'JustAnotherVoiceChat-%APPVEYOR_BUILD_VERSION%-GTMP.zip'
24 | name: GT-MP Resource
25 |
26 | - path: 'JustAnotherVoiceChat.Server.dll'
27 | name: Server x64
28 |
29 | install:
30 | - mkdir C:\projects\dependencies
31 | - cd C:\projects\dependencies
32 |
33 | # install cmake
34 | - set CMAKE_URL="https://cmake.org/files/v3.8/cmake-3.8.0-win64-x64.zip"
35 | - appveyor DownloadFile %CMAKE_URL% -FileName cmake.zip
36 | - 7z x cmake.zip -oC:\projects\deps > nul
37 | - move C:\projects\deps\cmake-* C:\projects\deps\cmake # Move to a version-agnostic directory
38 | - set PATH=C:\projects\deps\cmake\bin;%PATH%
39 | - cmake --version
40 |
41 | before_build:
42 | - cd C:\projects\justanothervoicechat-server
43 | - nuget restore
44 |
45 | # get submodules
46 | - ps: (Get-Content .gitmodules).replace('git@github.com:', 'https://github.com/') | Set-Content .gitmodules
47 | - git submodule update --init
48 |
49 | build_script:
50 | # C++
51 | - cd JustAnotherVoiceChat.Server
52 | - mkdir build
53 | - cd build
54 | - cmake .. -G "Visual Studio 15 2017 Win64"
55 | - cmake --build . --config Release
56 | - cp src\Release\JustAnotherVoiceChat.Server.dll C:\projects\justanothervoicechat-server\
57 | - move src\Release\JustAnotherVoiceChat.Server.dll ..\..\JustAnotherVoiceChat.Server.Wrapper\
58 |
59 | # C#
60 | - cd C:\projects\justanothervoicechat-server
61 | - dotnet build JustAnotherVoiceChat.Server.Wrapper\JustAnotherVoiceChat.Server.Wrapper.csproj -c "Release Windows" -f netstandard1.2
62 | - dotnet build JustAnotherVoiceChat.Server.GTMP\JustAnotherVoiceChat.Server.GTMP.csproj -c "Release Windows" -f net452
63 | - dotnet build JustAnotherVoiceChat.Server.GTMP.Resource\JustAnotherVoiceChat.Server.GTMP.Resource.csproj -c "Release Windows" -f net452
64 |
65 | after_build:
66 | - dotnet pack JustAnotherVoiceChat.Server.Wrapper/JustAnotherVoiceChat.Server.Wrapper.csproj -c "Release Windows" -o "..\"
67 | - nuget pack JustAnotherVoiceChat.Server.GTMP\JustAnotherVoiceChat.Server.GTMP.csproj -Properties "Configuration=Release Windows"
68 |
69 | # Build GT-MP Resource
70 | - cd C:\projects\justanothervoicechat-server\JustAnotherVoiceChat.Server.GTMP.Resource\bin\Release\Windows
71 | - 7z a JustAnotherVoiceChat-%APPVEYOR_BUILD_VERSION%-GTMP.zip JustAnotherVoiceChat* meta.xml Client\JustAnotherVoiceChat.js
72 | - move JustAnotherVoiceChat-%APPVEYOR_BUILD_VERSION%-GTMP.zip C:\projects\justanothervoicechat-server\
73 |
74 | test_script:
75 | - cd C:\projects\justanothervoicechat-server
76 | - dotnet test JustAnotherVoiceChat.Server.Wrapper.Tests\JustAnotherVoiceChat.Server.Wrapper.Tests.csproj -c "Release Windows" --logger trx;LogFileName=results.xml
77 |
78 | on_finish:
79 | - ps: |
80 | $wc = New-Object 'System.Net.WebClient'
81 | $files = Get-ChildItem -Include results.xml -Recurse
82 | foreach ($file in $files)
83 | {
84 | $wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", $file.FullName)
85 | }
86 |
87 | deploy:
88 | - provider: NuGet
89 | api_key:
90 | secure: qytdDzKfxkqRRaYiNfw2kI+8GAct937ZEDJjgUKsr5FfXccRE04Hl+r6eaj+Pifj
91 | skip_symbols: true
92 | artifact: /.*\.nupkg/
93 | on:
94 | branch: master
95 | appveyor_repo_tag: true
96 |
97 | - provider: GitHub
98 | auth_token:
99 | secure: b0P+CkQJzqs4JIluFMp+DMpQZ93e9ZzbzibKPOgaSDgzBgwUiIqKXtzSu7JaMQtJ
100 | release: $(APPVEYOR_REPO_TAG_NAME)
101 | prerelease: true
102 | draft: true
103 | description: $(APPVEYOR_REPO_COMMIT_MESSAGE)
104 | artifact: /.*\.nupkg/, JustAnotherVoiceChat-$(appveyor_build_version)-GTMP.zip, JustAnotherVoiceChat.Server.dll
105 | on:
106 | branch: master
107 | appveyor_repo_tag: true
108 |
--------------------------------------------------------------------------------
/docs/communication.md:
--------------------------------------------------------------------------------
1 | # JustAnotherVoiceChat communication
2 |
3 | ## Definitions
4 |
5 | * JustAnotherVoiceChat Client: The Teamspeak 3 plugin which controls the local teamspeak
6 | * JustAnotherVoiceChat Server: The server instance which controls the teamspeak plugin instances
7 | * Game Client: The actual game running on the users PC
8 | * Game Server: The multiplayer server for the actual game
9 |
10 | ## General idea
11 |
12 | The JustAnotherVoiceChat teamspeak plugin is the *main component*. It un-/mutes teamspeak clients and changes their volume and positional audio. The needed information is send by the *JustAnotherVoiceChat Server* to each *JustAnotherVoiceChat client* which is controlled by the *game server*.
13 | The *game client* only talks on connection setup with the *JustAnotherVoiceChat client* to give *JustAnotherVoiceChat client* about the *JustAnotherVoiceChat server* and unique client identifier.
14 |
15 | 
16 |
17 | ## Connection setup
18 |
19 | When the *game client* connects to the *game server* the server tells the client about the needed information (endpoint, client unique identifier) to connect to the *JustAnotherVoiceChat server*. The *game client* then sends this information (via the local connection) to the *JustAnotherVoiceChat client*. The *JustAnotherVoiceChat client* now has all information needed to connect the specific *JustAnotherVoiceChat server* which belongs to the *game server*. The *JustAnotherVoiceChat client* connects to the *JustAnotherVoiceChat server* and the server confirms the connection. When the connection was confirmed the client requests the client uid to teamspeak id mapping it needs to change teamspeak clients. With this information the connection setup is **completed**.
20 |
21 | 
22 |
23 | ## Continues updates
24 |
25 | When the *JustAnotherVoiceChat client* connection setup is completed it receives continues updates from the *JustAnotherVoiceChat server* about changed players. This is the **main message** the complete communication is about.
26 |
27 | 
28 |
29 | ### updatePlayersMessage
30 |
31 | The idea is to send as less information as possible but enough that the client can change the needed teamspeak clients. Information required to change a single clients is:
32 |
33 | * Player is in range to be heard
34 | * Range to the player to set volume modifier
35 | * Stereo position of the player to set audio pan
36 |
--------------------------------------------------------------------------------
/docs/diagrams/client-communication.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/diagrams/client-communication.dia
--------------------------------------------------------------------------------
/docs/diagrams/connection-setup.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/diagrams/connection-setup.dia
--------------------------------------------------------------------------------
/docs/diagrams/continues-communication.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/diagrams/continues-communication.dia
--------------------------------------------------------------------------------
/docs/diagrams/general-communication.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/diagrams/general-communication.dia
--------------------------------------------------------------------------------
/docs/diagrams/network-communication.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/diagrams/network-communication.dia
--------------------------------------------------------------------------------
/docs/images/JAVIC_Logo_Standalone_64px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/images/JAVIC_Logo_Standalone_64px.png
--------------------------------------------------------------------------------
/docs/images/JAVIC_Wide_250px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/images/JAVIC_Wide_250px.png
--------------------------------------------------------------------------------
/docs/images/client-communication.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/images/client-communication.png
--------------------------------------------------------------------------------
/docs/images/connection-setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/images/connection-setup.png
--------------------------------------------------------------------------------
/docs/images/continues-communication.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/images/continues-communication.png
--------------------------------------------------------------------------------
/docs/images/general-communication.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/images/general-communication.png
--------------------------------------------------------------------------------
/docs/images/network-communication.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlternateLife/JustAnotherVoiceChat-Server/9b0afd04b1cf9a92e2c0cc66578f15598806dbf0/docs/images/network-communication.png
--------------------------------------------------------------------------------
/docs/installation-gtmp.md:
--------------------------------------------------------------------------------
1 | # Integration into a GT-MP server
2 |
3 | This manual offers a very basic guide how to integrate the JustAnotherVoiceServer into your own GT-MP server. For a more detailed showcase, how to use the server and resource, look into the [JustAnotherVoiceChat.Server.GTMP.Resource](https://github.com/AlternateLife/JustAnotherVoiceChat-Server/tree/master/JustAnotherVoiceChat.Server.GTMP.Resource) project.
4 |
5 | ## Requirements
6 |
7 | - Stable GT-MP Server
8 | - TeamSpeak3-Server with a password-protected channel.
9 | - You need to know the following information of the selected TeamSpeak3-Server:
10 | - Channel ID of the target channel, where the players will be moved
11 | - Password of that said channel
12 | - Unique server identity of your server *(Example: `FEymkeQpMFKW+uRsuoCWti5F3II=`)*
13 | - NuGet Package for GT-MP *(JustAnotherVoiceChat.Server.GTMP)*
14 |
15 | ## Very basic manual installation
16 |
17 | These steps guide you to a very basic JustAnotherVoiceChat server, that accepts connections and everyone should be able to hear you.
18 |
19 | > You can also find an example resource in the [JustAnotherVoiceChat.Server.GTMP.Resource](https://github.com/AlternateLife/JustAnotherVoiceChat-Server/tree/master/JustAnotherVoiceChat.Server.GTMP.Resource) project.
20 |
21 | 1. Install needed dependencies with NuGet
22 | ```
23 | PM> Install-Package JustAnotherVoiceChat.Server.GTMP
24 | ```
25 |
26 | 2. Create JustAnotherVoiceChat server instance on startup
27 | ```CSHARP
28 | public class MyGamemode : Script
29 | {
30 |
31 | private JustAnotherVoiceChat.Server.GTMP.IGtmpVoiceServer _voiceServer;
32 |
33 | public MyGamemode()
34 | {
35 | API.onResourceStop += OnResourceStop;
36 | API.onResourceStart += OnResourceStart;
37 | }
38 |
39 | private void OnResourceStart()
40 | {
41 | _voiceServer = JustAnotherVoiceChat.Server.GTMP.Factories.GtmpVoice.CreateServer(API, new VoiceServerConfiguration("game.myexampleserver.com", 23332, "TeamSpekaIdentiy==", 232, "verySecretPassword"));
42 |
43 | // This line enables the 3D positional sound
44 | _voiceServer.AddTask(new PositionalVoiceTask());
45 |
46 | _voiceServer.OnClientPrepared += OnClientShouldReceiveHandshake;
47 | _voiceServer.OnClientDisconnected += OnClientShouldReceiveHandshake;
48 | _voiceServer.OnClientConnected += OnClientConnected;
49 |
50 | _voiceServer.Start();
51 | }
52 |
53 | private void OnResourceStop()
54 | {
55 | _voiceServer.Stop();
56 | _voiceServer.Dispose();
57 | }
58 |
59 | private void OnClientConnected(IGtmpVoiceClient client)
60 | {
61 | client.Player.triggerClientEvent("VOICE_HANDSHAKE", false, "");
62 | }
63 |
64 | private void OnClientShouldReceiveHandshake(IGtmpVoiceClient client)
65 | {
66 | client.Player.triggerEvent("VOICE_HANDSHAKE", true, client.HandshakeUrl);
67 | }
68 | }
69 | ```
70 |
71 | 3. Create a clientside script that sends a HTTP request to the local JustAnotherVoiceChat client **with a headless remote CEF browser**. This step is **necessary**, so the TeamSpeak-Client is able to connect to the JustAnotherVoiceChat server.
72 |
73 | ```JS
74 | let browser = null;
75 | let handshakeTimer = 0;
76 |
77 | API.onResourceStart.connect(() => {
78 | browser = API.createCefBrowser(0, 0, false);
79 | API.waitUntilCefBrowserInit(browser);
80 | API.setCefBrowserHeadless(browser, true);
81 | });
82 |
83 | API.onServerEventTrigger.connect((eventName, args) => {
84 | if(eventName !== "VOICE_HANDSHAKE") {
85 | return;
86 | }
87 |
88 | const newStatus = args[0];
89 | const handshakeUrl = args[1];
90 |
91 | if(newStatus) {
92 | handshakeTimer = API.every(3000, "resendHandshake", handshakeUrl);
93 | } else {
94 | if(handshakeTimer != -1) {
95 | API.stop(handshakeUrl);
96 | handshakeTimer = -1;
97 | }
98 | }
99 |
100 | });
101 |
102 | function resendHandshake(url) {
103 | API.loadPageCefBrowser(browser, url);
104 | }
105 | ```
106 |
107 | 4. Copy needed libraries to the resource-location
108 | ```
109 | JustAnotherVoiceChat.Server.dll
110 | JustAnotherVoiceChat.Server.Wrapper.dll
111 | JustAntoherVoiceChat.Server.GTMP.dll
112 | ```
113 |
114 | 5. Add assemblies to the resource's meta.xml.
115 | *The `JustAnotherVoiceChat.Server.dll` shouldn't be listed there, because it is a native C++ library.*
116 | ```
117 |
118 |
119 | ```
--------------------------------------------------------------------------------