public IEnumerator SetupNetworkServer() => RunAsync(async() => { serverGO = new GameObject(); var transport = serverGO.AddComponent <LoopbackTransport>(); server = serverGO.AddComponent <NetworkServer>(); await server.ListenAsync(); IConnection tconn = await transport.ConnectAsync(new System.Uri("tcp4://localhost")); connectionToClient = server.connections.First(); connectionToServer = new NetworkConnectionToServer(tconn); connectionToClient.isAuthenticated = true; connectionToServer.isAuthenticated = true; message = new WovenTestMessage { IntValue = 1, DoubleValue = 1.0, StringValue = "hello" }; identity = new GameObject().AddComponent <NetworkIdentity>(); identity.ConnectionToClient = connectionToClient; });
public override void OnClientAuthenticate(NetworkConnectionToServer conn) { Authenticator.OnClientAuthenticate(conn); if (Timeout > 0) { StartCoroutine(BeginAuthentication(conn)); } }
public override void OnClientAuthenticate(NetworkConnectionToServer conn) { var authRequestMessage = new AuthRequestMessage { AuthUsername = Username, AuthPassword = Password }; manager.client.Send(authRequestMessage); }
public static (NetworkConnectionToServer, NetworkConnectionToClient) PipedConnections(bool authenticated = false) { (IConnection c1, IConnection c2) = PipeConnection.CreatePipe(); var toServer = new NetworkConnectionToServer(c2); var toClient = new NetworkConnectionToClient(c1); toServer.isAuthenticated = authenticated; toClient.isAuthenticated = authenticated; return(toServer, toClient); }
public override void OnClientAuthenticate(NetworkConnectionToServer conn) { conn.RegisterHandler <NetworkConnectionToServer, AuthResponseMessage>(OnAuthResponseMessage, false); var authRequestMessage = new AuthRequestMessage { AuthUsername = Username, AuthPassword = Password }; conn.Send(authRequestMessage); }
public void OnAuthResponseMessage(NetworkConnectionToServer conn, AuthResponseMessage msg) { if (msg.Code == 100) { Debug.LogFormat("Authentication Response: {0}", msg.Message); // Invoke the event to complete a successful authentication base.OnClientAuthenticate(conn); } else { Debug.LogErrorFormat("Authentication Response: {0}", msg.Message); // Set this on the client for local reference conn.isAuthenticated = false; // disconnect the client conn.Disconnect(); } }