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