public void VerifyResponse(NetWorker networker, NetworkingPlayer player, BMSByte response, System.Action <NetworkingPlayer> authUserAction, System.Action <NetworkingPlayer> rejectUserAction) { uint id; switch (status) { case Server.AuthStatus.Available: id = response.GetBasicType <uint>(); BinaryFormatter binFor = new BinaryFormatter(); MemoryStream memStream = new MemoryStream(); byte[] bytes = response.GetByteArray(sizeof(uint)); memStream.Write(bytes, 0, bytes.Length); memStream.Position = 0; List <uint> ids = binFor.Deserialize(memStream) as List <uint>; if (ids.Contains(id)) { ids.Remove(id); authUserAction(player); status = Server.AuthStatus.Checking; allowedIds = ids; } else { rejectUserAction(player); } //uint[] ids = ObjectMapper.Instance.Map<uint[]>(response); break; case Server.AuthStatus.Checking: id = response.GetBasicType <uint>(); if (allowedIds.Contains(id)) { authUserAction(player); allowedIds.Remove(id); } else { rejectUserAction(player); } return; case Server.AuthStatus.Closed: rejectUserAction(player); return; } }
public void AcceptChallenge(NetWorker networker, BMSByte challenge, Action <BMSByte> authServerAction, Action rejectServerAction) { Server.AuthStatus status = challenge.GetBasicType <Server.AuthStatus>(); switch (status) { case Server.AuthStatus.Available: List <uint> memberIds = new List <uint>(); /*foreach (Friend f in ourLobby.Members) * { * memberIds.Add(f.Id.AccountId); * }*/ BMSByte response = ObjectMapper.BMSByte(SteamClient.SteamId.AccountId); BinaryFormatter binFor = new BinaryFormatter(); MemoryStream memStream = new MemoryStream(); binFor.Serialize(memStream, memberIds); //response.Append(ObjectMapper.BMSByte(memberIds.ToArray())); response.Append(ObjectMapper.BMSByte(memStream.ToArray())); authServerAction(response); memStream.Close(); return; case Server.AuthStatus.Checking: authServerAction(ObjectMapper.BMSByte(SteamClient.SteamId.AccountId)); return; case Server.AuthStatus.Closed: rejectServerAction(); return; } /* * BMSByte by = new BMSByte(); * var binFormatter = new BinaryFormatter(); * var mStream = new MemoryStream(); * binFormatter.Serialize(mStream, allowedSteamIDs); * * var data = ObjectMapper.BMSByte(mStream.ToArray()); * * authServerAction(data); */ }
void ResetServer() { if (NetworkManager.Instance != null && NetworkManager.Instance.Networker != null) { if (networkObject != null) { networkObject.SendRpc(RPC_ALL_PLAYERS_LEAVE_LOBBY, Receivers.All); } DeleteObjects(); Debug.Log("about to disconnect server."); lock (NetworkManager.Instance.Networker.Players) { foreach (var player in NetworkManager.Instance.Networker.Players) { if (player != null) { ((IServer)NetworkManager.Instance.Networker).Disconnect(player, true); } } ((IServer)NetworkManager.Instance.Networker).CommitDisconnects(); } NetworkManager.Instance.Disconnect(); Debug.Log("server disconnected."); StartCoroutine(BootUpServerAgain()); Debug.Log("booting up server again..."); serverHasBeenReset = true; status = Server.AuthStatus.Available; } }