Exemple #1
0
        /// <summary>
        /// Set the ready state for communication to true, send a packet to the connection
        /// </summary>
        /// <param name="sent">If the sending of the packet succeeds or fails</param>
        public void SetConnectionReady()
        {
            communicationReady = true;

            Packet p = new Packet();

            p.WriteByte((byte)NetworkMsg.Ready);
            p.WriteByte((byte)ConnectionState.Connecting);
            p.FinishWriting();

            SockInterface.Send(p, connectionInfo.Peer, SendOptions.ReliableOrdered);

            SocketLog.Info("Communication socket ready and open sent to {0}", connectionInfo.Peer.ConnectId);
        }
Exemple #2
0
        public void SetToken(int dataSize, byte[] data)
        {
            //Initialization
            NetworkMsg msgType = NetworkMsg.Unknown;
            byte       type;
            int        size;
            //Read the packet and convert it to a byte array
            IMessageRider token = SockInterface.ReadToken(dataSize, data, out type, out size);

            //Convert the type into a enum readable type
            msgType = (NetworkMsg)type;
            //Handle the token
            HandleToken(msgType, token);
            SocketLog.Info("Set token type {0} for connection {1}", msgType, ConnectionInfo.Peer.ConnectId);
        }
Exemple #3
0
        public bool SendToken(byte[] data, int dataSize, NetworkMsg type)
        {
            byte[] newData = socketInterface.WriteToken(data, type);

            return(SockInterface.SendToken(connectionInfo.Peer, newData));
        }
Exemple #4
0
 public void Disconnect(IMessageRider token)
 {
     SockInterface.Disconnect(this, token);
 }
Exemple #5
0
 public void Disconnect()
 {
     SockInterface.Disconnect(connectionInfo.Peer);
 }