Beispiel #1
0
        ///Add a session ack to send to client
        public static void AddSession(Session MySession, List <byte> OutGoingMessage)
        {
            Logger.Info("Adding Session Data");
            if (!MySession.remoteMaster)
            {
                ///Add first portion of session
                OutGoingMessage.InsertRange(0, BitConverter.GetBytes(MySession.sessionIDBase));
            }

            else
            {
                ///Ack session, first add 2nd portion of Session
                OutGoingMessage.InsertRange(0, Utility_Funcs.Pack(MySession.sessionIDUp));

                ///Add first portion of session
                OutGoingMessage.InsertRange(0, BitConverter.GetBytes(MySession.sessionIDBase));
            }
        }
Beispiel #2
0
        public static void AddSessionHeader(Session MySession, List <byte> OutGoingMessage, ushort PacketLength)
        {
            uint value = 0;

            Logger.Info("Adding Session Header");

            if (!MySession.Instance) //When server initiates instance with the client, it will use this
            {
                value |= 0x80000;
            }

            //This would be if we want to cancel the connection... Client handles this in most cases? For now.
            //if (MySession.CancelConnection) //
            //{
            //    value += 0x10000;
            //}

            if (MySession.remoteMaster) // Purely a guess.... Something is 0x4000 in this and seems to correspond the initator of the session
            {
                value |= 0x04000;
            }

            else // Server is not master, seems to always have this when not in control
            {
                value |= 0x01000;
            }

            if (MySession.hasInstance) // Server always has instance ID, atleast untill we are in world awhile, then it can drop this and the 4 byte instance ID
            {
                value |= 0x02000;
            }

            //Add bundle length in
            value |= PacketLength;

            ///Combine, switch endianness and place into Packet
            OutGoingMessage.InsertRange(0, Utility_Funcs.Pack(value));
        }