Beispiel #1
0
 public User(string username, NetworkCommsDotNet.Connections.Connection connection)
 {
     _Card        = null;
     _Ping        = 0;
     _ReadyToPlay = false;
     _Username    = username;
     _Connection  = connection;
     _Ip          = new myNetwork_IP(connection.ConnectionInfo.RemoteEndPoint.ToString().Split(':').First(), int.Parse(connection.ConnectionInfo.RemoteEndPoint.ToString().Split(':').Last()));
 }
        /// <summary>
        /// Initialise a new PriorityQueueItem
        /// </summary>
        /// <param name="priority"></param>
        /// <param name="connection"></param>
        /// <param name="packetHeader"></param>
        /// <param name="dataStream"></param>
        /// <param name="sendReceiveOptions"></param>
        public PriorityQueueItem(QueueItemPriority priority, Connection connection, PacketHeader packetHeader, MemoryStream dataStream, SendReceiveOptions sendReceiveOptions)
        {
            if (connection == null) throw new ArgumentNullException("connection", "Provided Connection parameter cannot be null.");
            if (packetHeader == null) throw new ArgumentNullException("packetHeader", "Provided PacketHeader parameter cannot be null.");
            if (dataStream == null) throw new ArgumentNullException("dataStream", "Provided MemoryStream parameter cannot be null.");
            if (sendReceiveOptions == null) throw new ArgumentNullException("sendReceiveOptions", "Provided sendReceiveOptions cannot be null.");

            this.Priority = priority;
            this.Connection = connection;
            this.PacketHeader = packetHeader;
            this.DataStream = dataStream;
            this.SendReceiveOptions = sendReceiveOptions;
        }
            public C2SAskEnterCharSelect(ByteBuffer buffer, NetworkCommsDotNet.Connections.Connection connection) :
                base(118, connection)
            {
                //TODO figure out packet struct
                unk1   = buffer.ReadBlock(2);
                userID = BitConverter.ToInt32(buffer.ReadBlock(5), 0);
                var uname = buffer.ReadBlock(50);

                for (int i = 0; i < uname.Length; i++)
                {
                    if (uname[i] == 0)
                    {
                        byte[] help = new byte[i];
                        Array.Copy(uname, help, i);
                        username = Encoding.ASCII.GetString(help);
                        break;
                    }
                }
            }
        /// <summary>
        /// Performs whatever functions we might so desire when we receive an incoming ChatMessage
        /// </summary>
        /// <param name="header">The PacketHeader corresponding with the received object</param>
        /// <param name="connection">The Connection from which this object was received</param>
        /// <param name="incomingMessage">The incoming ChatMessage we are after</param>
        protected override void HandleIncomingChatMessage(PacketHeader header, Connection connection, ChatMessage incomingMessage)
        {
            //We call the base that handles everything
            base.HandleIncomingChatMessage(header, connection, incomingMessage);

            //Once the base is complete we refresh the messages from box
            RefreshMessagesFromBox();
        }