public override void OnConnect(NetDriverConnection connection) { Assert.IsNull(_serverConnection); _serverConnection = new ActorReplicationChannel(new NetConnection(this, connection)); _serverConnection.ResetTimeoutForTravel(); connection.outer = _serverConnection; Debug.Log("Connected to server (" + connection.address + ")"); }
public override void OnConnect(NetDriverConnection connection) { base.OnConnect(connection); if (gameMode == null) { DisconnectClient(connection.outer.connection, null, EDisconnectReason.Error, "Error.Networking.NotReady"); return; } gameMode.AcceptConnection(connection.outer); }
public override void OnDisconnect(NetDriverConnection connection) { var channel = connectionList.Find(x => (x.connection.driverConnection == connection)); if ((channel != null) && connectionList.Remove(channel)) { if (channel.owningPlayer != null) { OnPlayerDisconnected(channel.owningPlayer, null, 0, null); } Debug.Log("Client disconnected (" + connection.address + ")."); } }
public void OnMessageReceived(NetDriverConnection connection, byte[] data, int size) { #if !UNITY_EDITOR try { #endif RawNetRecv(connection.outer, size); #if !UNITY_EDITOR } catch (Exception e) { OnRawNetRecvError(connection, e); } #endif }
public override void OnConnect(NetDriverConnection connection) { var channel = new ActorReplicationChannel(new NetConnection(this, connection)); channel.connection.SetID(++nextConnectionID); channel.connection.driverConnection.blocking = true; connection.outer = channel; connectionList.Add(channel); Debug.Log("Client connected (" + connection.address + ")."); channel.connection.SendReliable(NetMsgs.Welcome.New(serverName, serverMessage, channel.connection.id)); }
public override void OnDisconnect(NetDriverConnection connection) { if (_connectionState == EConnectionState.Connecting) { Debug.Log("Cannot connect to server!"); } else { Debug.Log("Disconnected from server (" + connection.address + ")"); _connectionState = EConnectionState.Disconnected; _serverConnection = null; OnDisconnectedFromServer(EDisconnectReason.Error); } }
public override void OnReliableSendWouldBlock(NetDriverConnection connection) { var channel = connectionList.Find(x => (x.connection.driverConnection == connection)); if (channel != null) { connection.blocking = true; DisconnectClient(channel.connection, null, EDisconnectReason.Error, "WouldBlock"); } else { connection.Dispose(); } }
public override void OnRawNetRecvError(NetDriverConnection connection, Exception e) { if (e != null) { Debug.LogException(e); var msg = "Server Reported Error: "; if (e.InnerException != null) { msg += e.InnerException.Message + "\n" + e.InnerException.StackTrace + "\n\n" + e.Message + "\n" + e.StackTrace; } else { msg += e.Message + "\n" + e.StackTrace; } DisconnectClient(connection.outer.connection, e, EDisconnectReason.Error, msg); } else { DisconnectClient(connection.outer.connection, null, EDisconnectReason.Error, null); } }
public override void OnReliableSendWouldBlock(NetDriverConnection connection) { connection.blocking = true; OnDisconnect(connection.outer, EDisconnectReason.Error, "WouldBlock"); }
public NetConnection(World world, NetDriverConnection connection) { inner = connection; _world = world; }
public virtual void OnRawNetRecvError(NetDriverConnection connection, Exception e) { Debug.LogException(e); OnInvalidMessageReceived(connection); }
public void OnInvalidMessageReceived(NetDriverConnection connection) { Debug.LogError("Received bad packet from (" + connection.address + "), disconnecting."); connection.Dispose(); }
public abstract void OnReliableSendWouldBlock(NetDriverConnection connection);
public abstract void OnDisconnect(NetDriverConnection channel);
public abstract void OnConnect(NetDriverConnection connection);