Пример #1
0
        public byte[] GetBytes()
        {
            byte[] Data   = new byte[Length + 3];
            byte[] Header = Base64Encoding.EncodeUint32(mMessageId, 2);

            Data[0] = Header[0];
            Data[1] = Header[1];

            for (int i = 0; i < Length; i++)
            {
                Data[i + 2] = mBody[i];
            }

            Data[Data.Length - 1] = 1;

            return(Data);
        }
Пример #2
0
        public static void HandleData(Session Session, ClientMessage Message)
        {
            if (Session == null || Session.Stopped || Message == null)
            {
                return;
            }

            if (!mCallbacks.ContainsKey(Message.Id))
            {
                Output.WriteLine("Unhandled packet: " + Message.Id + " (" + Constants.DefaultEncoding.GetString(Base64Encoding.EncodeUint32(Message.Id, 2)) + "), no suitable handler found.", OutputLevel.Warning);
                return;
            }

            if (!Session.Authenticated && !mCallbacksWithoutAuthentication.Contains(Message.Id))
            {
                return;
            }

            mCallbacks[Message.Id].Invoke(Session, Message);
        }