public IEnumerator CommandsAndRPCCallsWorkTest() { NetworkClient.ShutdownAll(); NetworkServer.Reset(); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced);// this test requires correct sequence of packets. config.AddChannel(QosType.Unreliable); myClient = new NetworkClient(); if (!myClient.Configure(config, 10)) { Assert.Fail("Client configure failed"); } NetworkServer.RegisterHandler(MsgType.AddPlayer, OnAddPlayer); myClient.RegisterHandler(MsgType.Connect, OnClientConnected); myClient.RegisterHandler(MsgType.Error, OnClientError); ClientScene.RegisterSpawnHandler(playerHash, OnSpawnPlayer, OnUnSpawnPlayer); int retries = 0; while (!NetworkServer.Listen("127.0.0.1", ++kListenPort)) { Assert.IsTrue(retries++ < 10, "Couldn't Listen for more than 10 retries"); } myClient.Connect("127.0.0.1", kListenPort); while (!isTestDone) { yield return(null); } }
public IEnumerator set_up() { string nameKeep = "https://script.google.com/macros/s/AKfycbyHApaejkQCI43E6QinTT3Pc1RGHGxh4Cgfm3Da2YuHvApbBlY/exec"; WWWForm form = new WWWForm(); form.AddField("Request", "Get"); form.AddField("IP", "This Can be left empty"); using (UnityWebRequest request_test = UnityWebRequest.Post(nameKeep, form)) { yield return(request_test.SendWebRequest()); string response_ret = request_test.downloadHandler.text; myClient = new NetworkClient(); ConnectionConfig myConfig = new ConnectionConfig(); channel_ID = (int)myConfig.AddChannel(QosType.ReliableFragmented); myConfig.PacketSize = 1999; myConfig.FragmentSize = 1500; myConfig.MaxSentMessageQueueSize = 200; myClient.Configure(myConfig, 100); myClient.Connect(response_ret.Substring(1, response_ret.Length - 2), 8362); isAtStartup = false; myClient.RegisterHandler(chatMessage, ReceiveMessage); //connect the event of receiving a server message myClient.RegisterHandler(LeaveEvent, ConnectionLost); } }
public void init(Client_Engine eng) { e = eng; ConnectionConfig conf = new ConnectionConfig(); conf.AddChannel(QosType.ReliableFragmented); conf.AddChannel(QosType.UnreliableFragmented); conf.ConnectTimeout = 1000; conf.MaxConnectionAttempt = 5; Client = new NetworkClient(); Client.Configure(conf, 1); Client.RegisterHandler(MsgType.Connect, net_onServerConnect); Client.RegisterHandler(MsgType.Error, net_onError); Client.RegisterHandler(MsgType.Disconnect, net_onServerDisconnect); Client.RegisterHandler(OPCodes.S2GC_AskLoginResponse, net_onAskLoginResponse); Client.RegisterHandler(OPCodes.S2GC_AskCharacterListResponse, net_onCharacterListResponse); Client.RegisterHandler(OPCodes.S2GC_AskCreateCharacterResponse, net_onAskCreateCharacterResponse); Client.RegisterHandler(OPCodes.S2GC_AskDeleteCharacterResponse, net_onAskDeleteCharacterResponse); Client.RegisterHandler(OPCodes.S2GC_AskEnterWorldResponse, net_onAskEnterWorldResponse); Client.RegisterHandler(OPCodes.S2GC_ClientPlayerSpawn, net_onClientSelfSpawn); Client.RegisterHandler(OPCodes.S2GC_OtherClientSpawn, net_onOtherClientSpawn); Client.RegisterHandler(OPCodes.S2GC_FullClientList, net_onFullClientList); Client.RegisterHandler(OPCodes.S2GC_UpdatePlayerStates, net_onUpdatePlayerStates); Client.RegisterHandler(OPCodes.S2GC_UpdateNPCStates, net_onUpdateNPCStates); Client.RegisterHandler(OPCodes.S2GC_FullNPCList, net_onFullNPCList); Client.RegisterHandler(OPCodes.S2GC_UpdateEntityStates, net_onUpdateEnityStates); Client.RegisterHandler(OPCodes.S2GC_OtherClientDisconnect, net_onOtherClientDisconnect); Client.RegisterHandler(OPCodes.S2GC_CastSpell, net_onSpellCast); Client.RegisterHandler(OPCodes.GC2S2GC_ChatMessage, net_onChatMessage); Client.RegisterHandler(OPCodes.S2GC_PlayerEnterCombat, net_onEnterCombat); Client.RegisterHandler(OPCodes.S2GC_PlayerExitCombat, net_onExitCombat); Client.RegisterHandler(OPCodes.S2GC_GiveQuest, net_onGivenQuest); Client.RegisterHandler(OPCodes.S2GC_UpdateQuest, net_onUpdateQuests); }
public IEnumerator ConnectWithDNSWorksTest() { NetworkServer.Reset(); NetworkClient.ShutdownAll(); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); NetworkClient client1 = new NetworkClient(); if (!client1.Configure(config, 20)) { Assert.Fail("client1 configure failed"); } client1.RegisterHandler(MsgType.Error, OnError1); NetworkClient client2 = new NetworkClient(); if (!client2.Configure(config, 20)) { Assert.Fail("client2 configure failed"); } client2.RegisterHandler(MsgType.Connect, OnConnectIncrementStep); NetworkClient client3 = new NetworkClient(); if (!client3.Configure(config, 20)) { Assert.Fail("client3 configure failed"); } client3.RegisterHandler(MsgType.Connect, OnConnectIncrementStep); int retries = 0; while (!NetworkServer.Listen("127.0.0.1", ++kListenPort)) { Assert.IsTrue(retries++ < 10, "Couldn't Listen for more than 10 retries"); } // wait for errors from client1 #if PLATFORM_WINRT && !ENABLE_IL2CPP LogAssert.Expect(LogType.Error, "DNS resolution failed: HostNotFound"); LogAssert.Expect(LogType.Error, "UNet Client Error Connect Error: 11"); #else LogAssert.Expect(LogType.Error, "DNS resolution failed: 11001"); LogAssert.Expect(LogType.Error, "UNet Client Error Connect Error: 11"); #endif client1.Connect("444.555.444.333", kListenPort); // These are successful and should increment the step counter client2.Connect("localhost", kListenPort); client3.Connect("127.0.0.1", kListenPort); while (steps < 3) { yield return(null); } }
void CreateClient() { Debug.Log(GetType() + " creating client ... "); var config = new ConnectionConfig(); // Config the Channels we will use config.AddChannel(QosType.ReliableFragmented); config.AddChannel(QosType.UnreliableFragmented); // Create the client ant attach the configuration unetClient = new NetworkClient(); unetClient.Configure(config, 12); // Register the handlers for the different network messages registerHandlers(); if (!useLobbySystem()) { log("this client is flagged without lobby, attemping connection ..."); connectToIpPort(getConnectionIpAddress()); // localhost } else { Debug.LogWarning("using lobby system, app must implem it's own way to connect to server"); } }
public IEnumerator IsConnectedPropertyWorksOnDifferentClientsTest() { NetworkClient.ShutdownAll(); NetworkServer.Reset(); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); remoteClient = new NetworkClient(); if (!remoteClient.Configure(config, 10)) { Assert.Fail("Client configure failed"); } remoteClient.RegisterHandler(MsgType.Connect, OnClientConnected); Assert.IsFalse(remoteClient.isConnected); int retries = 0; while (!NetworkServer.Listen("127.0.0.1", ++kListenPort)) { Assert.IsTrue(retries++ < 10, "Couldn't Listen for more than 10 retries"); } remoteClient.Connect("127.0.0.1", kListenPort); while (!isTestDone) { yield return(null); } }
public void Start() { server = new NetworkServerSimple(); serverOnClientConnect += ServerOnClientConnect; serverOnClientDisconnect += ServerOnClientDisconnect; serverOnData += ServerOnData; server.RegisterHandler(MsgType.Connect, serverOnClientConnect); server.RegisterHandler(MsgType.Disconnect, serverOnClientDisconnect); server.RegisterHandler(TerminalMsgID, serverOnData); client = new NetworkClient(); clientOnConnect += ClientOnConnect; clientOnDisconnect += ClientOnDisconnect; clientOnData += ClientOnData; client.RegisterHandler(MsgType.Connect, clientOnConnect); client.RegisterHandler(MsgType.Disconnect, clientOnDisconnect); client.RegisterHandler(TerminalMsgID, clientOnData); ConnectionConfig myConfig = new ConnectionConfig(); reliableChannelId = myConfig.AddChannel(QosType.Reliable); unreliableChannelId = myConfig.AddChannel(QosType.Unreliable); server.Configure(myConfig, maxConnections); client.Configure(myConfig, maxConnections); }
public void Create() { if (__client == null) { __client = new NetworkClient(); if (onError != null) { __client.RegisterHandler(MsgType.Error, onError); } if (onConnect != null) { __client.RegisterHandler(MsgType.Connect, onConnect); } __client.RegisterHandler(MsgType.Disconnect, __OnDisconnect); __client.RegisterHandler((short)HostMessageType.Register, __OnRegistered); __client.RegisterHandler((short)HostMessageType.Unregister, __OnUnregistered); __client.RegisterHandler((short)HostMessageType.Rpc, __OnRpc); __client.Configure(hostTopology); } __client.Connect(ipAddress, port); }
IEnumerator StartClientE(TMP_InputField IPAddress) { ttimer = 0; myClient = new NetworkClient(); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.UnreliableSequenced); config.PacketSize = 1500; config.SendDelay = 0; config.AckDelay = 0; myClient.Configure(config, 8); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MyMessageTypes.Pong, OnPong); myClient.Connect(IPAddress.text, port); while (!myClient.isConnected) { Debug.Log("Still connecting to server"); ttimer += Time.deltaTime; if (ttimer > DCSeconds) { Debug.Log("Cant connect to server"); yield break; } yield return(new WaitForEndOfFrame()); } yield break; }
private void Start() { //get ip address since we aren't using NetworkManager and cannot use that singleton: ipAddress = "::ffff:" + IPManager.GetIP(ADDRESSFAM.IPv4); //setup: broadcastPort = broadcastingPort; Initialize(); StartAsClient(); //configurations: _client = new NetworkClient(); ConnectionConfig config = new ConnectionConfig(); PrimaryChannel = config.AddChannel(primaryQualityOfService); SecondaryChannel = config.AddChannel(secondaryQualityOfService); config.InitialBandwidth = initialBandwidth; HostTopology topology = new HostTopology(config, 1); _client.Configure(topology); //event hooks: _client.RegisterHandler(MsgType.Error, HandleNetworkError); _client.RegisterHandler(MsgType.Connect, HandleConnected); _client.RegisterHandler(MsgType.Disconnect, HandleDisconnected); _client.RegisterHandler((short)NetworkMsg.FloatMsg, HandleFloat); _client.RegisterHandler((short)NetworkMsg.FloatArrayMsg, HandleFloatArray); _client.RegisterHandler((short)NetworkMsg.IntMsg, HandleInt); _client.RegisterHandler((short)NetworkMsg.IntArrayMsg, HandleIntArray); _client.RegisterHandler((short)NetworkMsg.Vector2Msg, HandleVector2); _client.RegisterHandler((short)NetworkMsg.Vector2ArrayMsg, HandleVector2Array); _client.RegisterHandler((short)NetworkMsg.Vector3Msg, HandleVector3); _client.RegisterHandler((short)NetworkMsg.Vector3ArrayMsg, HandleVector3Array); _client.RegisterHandler((short)NetworkMsg.QuaternionMsg, HandleQuaternion); _client.RegisterHandler((short)NetworkMsg.QuaternionArrayMsg, HandleQuaternionArray); _client.RegisterHandler((short)NetworkMsg.Vector4Msg, HandleVector4); _client.RegisterHandler((short)NetworkMsg.Vector4ArrayMsg, HandleVector4Array); _client.RegisterHandler((short)NetworkMsg.RectMsg, HandleRect); _client.RegisterHandler((short)NetworkMsg.RectArrayMsg, HandleRectArray); _client.RegisterHandler((short)NetworkMsg.StringMsg, HandleString); _client.RegisterHandler((short)NetworkMsg.StringArrayMsg, HandleStringArray); _client.RegisterHandler((short)NetworkMsg.ByteMsg, HandleByte); _client.RegisterHandler((short)NetworkMsg.ByteArrayMsg, HandleByteArray); _client.RegisterHandler((short)NetworkMsg.ColorMsg, HandleColor); _client.RegisterHandler((short)NetworkMsg.ColorArrayMsg, HandleColorArray); _client.RegisterHandler((short)NetworkMsg.Color32Msg, HandleColor32); _client.RegisterHandler((short)NetworkMsg.Color32ArrayMsg, HandleColor32Array); _client.RegisterHandler((short)NetworkMsg.BoolMsg, HandleBool); _client.RegisterHandler((short)NetworkMsg.BoolArrayMsg, HandleBoolArray); _client.RegisterHandler((short)NetworkMsg.Matrix4x4Msg, HandleMatrix4x4); _client.RegisterHandler((short)NetworkMsg.Matrix4x4ArrayMsg, HandleMatrix4x4Array); }
public void OnClient1Disconnected(NetworkMessage netMsg) { client2 = new NetworkClient(); if (!client2.Configure(config, 10)) { Assert.Fail("Client2 configure failed"); } client2.RegisterHandler(MsgType.Connect, OnClient2Connected); client2.RegisterHandler(MsgType.Disconnect, OnClient2Disconnected); client2.Connect("127.0.0.1", kListenPort); }
private void connect() { ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.Reliable); config.AddChannel(QosType.Unreliable); client = new NetworkClient(); client.Configure(config, 1); client.Connect(ip, port); Log.Instance.Info("连接服务器......"); }
//===================================================== //Методы клиента //===================================================== void CreateClient() { var config = new ConnectionConfig(); // конфигурация используемых каналов config.AddChannel(QosType.ReliableFragmented); config.AddChannel(QosType.UnreliableFragmented); // создать клиента и присоединить конфигурацию client = new NetworkClient(); client.Configure(config, 1); RegisterHandlers(); }
public static NetworkClient ConnectClient(string address, int port, Action <NetworkConnection> onConnected, Action onDisconnect) { if (Client != null) { return(Client); } Client = new NetworkClient(); Client.Configure(NetworkConfiguration.GetHostTopology()); Client.Connect(address, port); Client.RegisterHandler(MsgType.Connect, m => CL_OnConnected(m, onConnected)); Client.RegisterHandler(MsgType.Disconnect, m => CL_OnDisconnect(m, onDisconnect)); return(Client); }
public IEnumerator ClientCanConnectAfterFailureTest() { NetworkClient.ShutdownAll(); NetworkServer.Reset(); NetworkServer.RegisterHandler(MsgType.Connect, OnServerConnected); config = new ConnectionConfig(); config.AddChannel(QosType.ReliableFragmented); if (!NetworkServer.Configure(config, 10)) { Assert.Fail("Server configure failed"); } // Mismatched channels between client 1 and server, so connect will fail with CRCMismatch error ConnectionConfig customConfig = new ConnectionConfig(); customConfig.AddChannel(QosType.UnreliableFragmented); client1 = new NetworkClient(); if (!client1.Configure(customConfig, 10)) { Assert.Fail("Client1 configure failed"); } client1.RegisterHandler(MsgType.Connect, OnClient1Connected); client1.RegisterHandler(MsgType.Disconnect, OnClient1Disconnected); int retries = 0; while (!NetworkServer.Listen("127.0.0.1", ++kListenPort)) { Assert.IsTrue(retries++ < 10, "Couldn't Listen for more than 10 retries"); } LogAssert.Expect(LogType.Error, "UNet Client Disconnect Error: CRCMismatch"); client1.Connect("127.0.0.1", kListenPort); while (!serverRecievedConnection || !isClientConnected) { yield return(null); } NetworkServer.DisconnectAll(); while (!isTestDone) { yield return(null); } }
public void Connect(string ip, int port) { var config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.UnreliableSequenced); config.PacketSize = 1470; var maxConnections = Constants.MultiplayerMaxConnections; _client = new NetworkClient(); _client.Configure(config, maxConnections); _client.Connect(ip, port); }
public void StartClient() { if (!isConnection) { ConnectionConfig conf = new ConnectionConfig(); conf.AddChannel(QosType.Reliable); conf.AddChannel(QosType.Unreliable); myClient = new NetworkClient(); myClient.Configure(conf, 1); myClient.Connect(IPAdress, Port); RegisterHandler(); } }
private void Start() { //setup: broadcastPort = broadcastingPort; Initialize(); StartAsClient(); //configurations: _client = new NetworkClient(); ConnectionConfig config = new ConnectionConfig(); PrimaryChannel = config.AddChannel(primaryQualityOfService); SecondaryChannel = config.AddChannel(secondaryQualityOfService); config.InitialBandwidth = initialBandwidth; HostTopology topology = new HostTopology(config, 1); _client.Configure(topology); //event hooks: _client.RegisterHandler(MsgType.Connect, HandleConnected); _client.RegisterHandler(MsgType.Disconnect, HandleDisconnected); _client.RegisterHandler((short)NetworkMsg.FloatMsg, HandleFloat); _client.RegisterHandler((short)NetworkMsg.FloatArrayMsg, HandleFloatArray); _client.RegisterHandler((short)NetworkMsg.IntMsg, HandleInt); _client.RegisterHandler((short)NetworkMsg.IntArrayMsg, HandleIntArray); _client.RegisterHandler((short)NetworkMsg.Vector2Msg, HandleVector2); _client.RegisterHandler((short)NetworkMsg.Vector2ArrayMsg, HandleVector2Array); _client.RegisterHandler((short)NetworkMsg.Vector3Msg, HandleVector3); _client.RegisterHandler((short)NetworkMsg.Vector3ArrayMsg, HandleVector3Array); _client.RegisterHandler((short)NetworkMsg.QuaternionMsg, HandleQuaternion); _client.RegisterHandler((short)NetworkMsg.QuaternionArrayMsg, HandleQuaternionArray); _client.RegisterHandler((short)NetworkMsg.Vector4Msg, HandleVector4); _client.RegisterHandler((short)NetworkMsg.Vector4ArrayMsg, HandleVector4Array); _client.RegisterHandler((short)NetworkMsg.RectMsg, HandleRect); _client.RegisterHandler((short)NetworkMsg.RectArrayMsg, HandleRectArray); _client.RegisterHandler((short)NetworkMsg.StringMsg, HandleString); _client.RegisterHandler((short)NetworkMsg.StringArrayMsg, HandleStringArray); _client.RegisterHandler((short)NetworkMsg.ByteMsg, HandleByte); _client.RegisterHandler((short)NetworkMsg.ByteArrayMsg, HandleByteArray); _client.RegisterHandler((short)NetworkMsg.ColorMsg, HandleColor); _client.RegisterHandler((short)NetworkMsg.ColorArrayMsg, HandleColorArray); _client.RegisterHandler((short)NetworkMsg.Color32Msg, HandleColor32); _client.RegisterHandler((short)NetworkMsg.Color32ArrayMsg, HandleColor32Array); _client.RegisterHandler((short)NetworkMsg.RectByteArrayMsg, HandleRectByteArray); _client.RegisterHandler((short)NetworkMsg.BoolMsg, HandleBool); _client.RegisterHandler((short)NetworkMsg.BoolArrayMsg, HandleBoolArray); }
public void OnClientDisconnected(NetworkMessage netMsg) { numConnects++; Assert.IsTrue(isServerRecivedConnection); isServerRecivedConnection = false; isClientConnected = false; myClient = new NetworkClient(); if (!myClient.Configure(config, 20)) { Assert.Fail("Client configure failed"); } myClient.RegisterHandler(MsgType.Connect, OnClientConnected); myClient.Connect("127.0.0.1", kListenPort); }
public IEnumerator HavingManyLocalClientsSimultaneouslyWorksTest() { NetworkClient.ShutdownAll(); NetworkServer.Reset(); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); NetworkServer.Configure(config, maxConnections); NetworkServer.RegisterHandler(MsgType.Connect, OnServerConnected); int retries = 0; while (!NetworkServer.Listen("127.0.0.1", ++kListenPort)) { Assert.IsTrue(retries++ < 10, "Couldn't Listen for more than 10 retries"); } for (int i = 0; i < numClients; ++i) { NetworkClient myClient = new NetworkClient(); if (!myClient.Configure(config, maxConnections)) { Assert.Fail("Client configure failed"); } myClient.RegisterHandler(MsgType.Connect, OnClientConnected); myClient.RegisterHandler(MsgType.Error, OnError); myClient.RegisterHandler(kMsgTest, OnClientTest); myClient.Connect("127.0.0.1", kListenPort); } while (serverConnections != numClients || clientsConnected != numClients) { yield return(null); } TestMessage testMsg = new TestMessage(); testMsg.number = 98756; testMsg.str = "teststring"; NetworkServer.SendToAll(kMsgTest, testMsg); while (msgCountClientRecieved != numClients) { yield return(null); } }
public virtual NetworkClient StartClient() { if (client != null) { return(client); } client = new NetworkClient(); RegisterClientMessages(client); client.Configure(connectionConfig, maxConnections); client.Connect(networkAddress, networkPort); isNetworkActive = true; OnStartClient(client); return(client); }
public void OnRegistrationClick() { registerSend = false; if (!isConnect) { ConnectionConfig conf = new ConnectionConfig(); conf.AddChannel(QosType.Reliable); conf.AddChannel(QosType.Unreliable); client = new NetworkClient(); client.Configure(conf, 1); client.Connect(myClient.IPAdress, myClient.Port); isConnect = true; client.RegisterHandler(Networking_msgType.Registration, OnServerAnswer); } }
// Use this for initialization void Start() { cli = new NetworkClient(); ConnectionConfig config = new ConnectionConfig(); config.FragmentSize = 8; config.PacketSize = 256; config.MaxSentMessageQueueSize = 4; config.MaxCombinedReliableMessageSize = 4; config.WebSocketReceiveBufferMaxSize = 4; config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); cli.Configure(config, 1); cli.RegisterHandler(NetMsgId.vibrate, (msg) => SetIP()); }
public void CreateClient() { var config = new ConnectionConfig(); // Config the Channels we will use config.AddChannel(QosType.ReliableFragmented); config.AddChannel(QosType.UnreliableFragmented); // Create the client ant attach the configuration client = new NetworkClient(); client.Configure(config, 1); // Register the handlers for the different network messages RegisterHandlers(); }
// CONSTRUCTOR public Client(NetworkingInfo netinfo) { networkingInfo = netinfo; if (networkingInfo.port == -1) { networkingInfo.port = NetworkingInfo.defaultPort; } if (networkingInfo.address == "") { networkingInfo.address = NetworkingInfo.defaultAddress; } // TODO: Add some kind of DNS pre check for IP? connectedPlayers = new List <Player>(); config = new ConnectionConfig(); Channels.priority = config.AddChannel(QosType.AllCostDelivery); Channels.reliable = config.AddChannel(QosType.ReliableSequenced); Channels.unreliable = config.AddChannel(QosType.UnreliableSequenced); Channels.fragmented = config.AddChannel(QosType.ReliableFragmented); Channels.update = config.AddChannel(QosType.StateUpdate); hostconfig = new HostTopology(config, maxConcurrentConnectedUsers); if (networkingInfo.isServer) { myClient = ClientScene.ConnectLocalServer(); myClient.Configure(hostconfig); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MsgType.Disconnect, ConnectionFailed); registerAllCallbacks(myClient, cbClientHandler); } else { myClient = new NetworkClient(); myClient.Configure(hostconfig); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MsgType.Error, ConnectionError); myClient.RegisterHandler(MsgType.Disconnect, ConnectionFailed); registerAllCallbacks(myClient, cbClientHandler); common.printConsole(tag, "Setup complete", true); myClient.Connect(networkingInfo.address, networkingInfo.port); common.printConsole(tag, "Connecting to " + networkingInfo.address + ":" + networkingInfo.port, true); } }
public ClientNetworking(IRPCParser parser, string ip, int port) { _port = port; _ip = ip; _rcpParser = parser; var config = new ConnectionConfig(); config.AddChannel(QosType.Reliable); config.AddChannel(QosType.Unreliable); _client = new NetworkClient(); _client.Configure(config, 1); RegisterHandlers(); }
public void StartClient(string ip, int port) { if (UIManager.Instance.playerName.text == "") { UIManager.Instance.NotName(); return; } var config = new ConnectionConfig(); config.AddChannel(QosType.ReliableFragmented); config.AddChannel(QosType.UnreliableFragmented); client = new NetworkClient(); client.Configure(config, 1); RegisterHandlers(); client.Connect(ip, port); }
public void Connect() { client = new NetworkClient(); var config = new ConnectionConfig(); config.AddChannel(QosType.ReliableFragmented); config.AddChannel(QosType.UnreliableFragmented); client.Configure(config, 1); RegisterHandles(); client.Connect(ip, port); IsRuning = true; }
private void SetupClient() { client = new NetworkClient(); HostTopology topology = new HostTopology(CreateConnectionConfig(), 3000); client.Configure(topology); client.RegisterHandler(MsgType.Connect, OnConnect); client.RegisterHandler(MsgType.Disconnect, OnDisconnect); client.RegisterHandler(MsgType.Error, OnError); client.RegisterHandler(ScopeMsgType.EnterScope, OnEnterScope); client.RegisterHandler(ScopeMsgType.ExitScope, OnExitScope); client.RegisterHandler(ScopeMsgType.SwitchScope, OnSwitchScope); client.RegisterHandler(ScopeMsgType.DisconnectMessage, OnDisconnectMessage); client.RegisterHandler(ScopeMsgType.RedirectMessage, OnRedirectMessage); }
public IEnumerator DisconnectAllWorksTest() { NetworkClient.ShutdownAll(); NetworkServer.Reset(); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); NetworkServer.Configure(config, maxConnections); NetworkServer.RegisterHandler(MsgType.Connect, OnServerConnected); int retries = 0; while (!NetworkServer.Listen("127.0.0.1", ++kListenPort)) { Assert.IsTrue(retries++ < 10, "Couldn't Listen for more than 10 retries"); } for (int i = 0; i < numClients; ++i) { NetworkClient myClient = new NetworkClient(); if (!myClient.Configure(config, maxConnections)) { Assert.Fail("Client configure failed"); } myClient.RegisterHandler(MsgType.Connect, OnClientConnected); myClient.RegisterHandler(MsgType.Disconnect, OnClientDisconnected); myClient.Connect("127.0.0.1", kListenPort); } while (serverConnections != numClients || clientsConnected != numClients) { yield return(null); } NetworkServer.DisconnectAll(); while (clientsDisccnnected != numClients) { yield return(null); } Assert.IsTrue(NetworkServer.active, "NetworkServer should still be active after DisconnectAll()"); }