Пример #1
0
        public static async void HandleJoinRequest(JoinRequest joinRequest, AuthSession session)
        {
            var serverSalt = new byte[0].GenerateRandomKey(4);

            session.GenerateSessionKey(BitConverter.GetBytes(joinRequest.ClientSalt), serverSalt);

            // Continue if sessionKey is not empty
            if (session.GameAccount.SessionKey != "")
            {
                var joinResponse = new JoinResponse
                {
                    RealmCount = Manager.RealmMgr.RealmList.Count,
                    ServerSalt = BitConverter.ToUInt32(serverSalt, 0)
                };

                foreach (var realm in Manager.RealmMgr.RealmList)
                {
                    var cRealm = Manager.RealmMgr.GetRealm(realm.Value.Id);

                    if (cRealm == null)
                    {
                        session.Dispose();
                        break;
                    }

                    var ip = IPAddress.Parse(cRealm.IPAddress).GetAddressBytes();
                    var port = BitConverter.GetBytes(cRealm.Port);

                    Array.Reverse(port);

                    joinResponse.RealmInfo.Add(Tuple.Create(ip, port));
                }

                await session.Send(joinResponse);
            }
        }
Пример #2
0
        public static void HandleDisconnect(Disconnect disconnect, AuthSession session)
        {
            Log.Debug($"Client '{session.ConnectionInfo}' disconnected.");

            session.Dispose();
        }