예제 #1
0
 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 + ")");
 }
예제 #2
0
        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);
        }
예제 #3
0
        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 + ").");
            }
        }
예제 #4
0
    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
    }
예제 #5
0
        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));
        }
예제 #6
0
 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);
     }
 }
예제 #7
0
        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();
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
 public override void OnReliableSendWouldBlock(NetDriverConnection connection)
 {
     connection.blocking = true;
     OnDisconnect(connection.outer, EDisconnectReason.Error, "WouldBlock");
 }
예제 #10
0
 public NetConnection(World world, NetDriverConnection connection)
 {
     inner  = connection;
     _world = world;
 }
예제 #11
0
 public virtual void OnRawNetRecvError(NetDriverConnection connection, Exception e)
 {
     Debug.LogException(e);
     OnInvalidMessageReceived(connection);
 }
예제 #12
0
 public void OnInvalidMessageReceived(NetDriverConnection connection)
 {
     Debug.LogError("Received bad packet from (" + connection.address + "), disconnecting.");
     connection.Dispose();
 }
예제 #13
0
 public abstract void OnReliableSendWouldBlock(NetDriverConnection connection);
예제 #14
0
 public abstract void OnDisconnect(NetDriverConnection channel);
예제 #15
0
 public abstract void OnConnect(NetDriverConnection connection);