private Guid AssignNewZoneServerToken(ActiveZoneServer zoneserver) { Guid newguid = Guid.NewGuid(); zoneserver.token = newguid.ToString(); _activezoneservers[zoneserver.username] = zoneserver; return(newguid); }
private void OnZoneServerWorldAuthenticationRequest(NetworkMessage netMsg) { string[] requestdata = netMsg.reader.ReadString().Split('|'); if (IsZoneAccountValid(requestdata[0], requestdata[1])) { ActiveZoneServer zoneserver = new ActiveZoneServer(); zoneserver.username = requestdata[0]; zoneserver.hostname = requestdata[2]; zoneserver.port = Convert.ToDecimal(requestdata[3]); zoneserver.zonename = requestdata[4]; zoneserver.connid = netMsg.conn.connectionId; Guid token = AssignNewZoneServerToken(zoneserver); NetworkServer.SendToClient(netMsg.conn.connectionId, EverMsgType.ZoneServerWorldAuthenticationResponse, new StringMessage("1|" + token.ToString())); // Locate any users pending this zone bootup and send them to it List <int> connidstoremove = new List <int>(); foreach (KeyValuePair <int, ActiveZoneServer> pendinguser in _pendinguserzonebootup) { if (!pendinguser.Value.username.Equals(zoneserver.username)) { continue; } NetworkServer.SendToClient(pendinguser.Key, EverMsgType.WorldServerUserConnectToZoneRequest, new StringMessage(zoneserver.hostname + "|" + zoneserver.port)); connidstoremove.Add(pendinguser.Key); } foreach (int connid in connidstoremove) { _pendinguserzonebootup.Remove(connid); } } else { NetworkServer.SendToClient(netMsg.conn.connectionId, EverMsgType.ZoneServerWorldAuthenticationResponse, new StringMessage("0|0")); } }
public void MovePlayerToZoneServer(int connectionid, string zonename) { ActiveZoneServer targetzoneserver = new ActiveZoneServer(); bool locatedzone = false; foreach (KeyValuePair <string, ActiveZoneServer> keypair in _activezoneservers) { if (keypair.Value.zonename.Equals(zonename)) { targetzoneserver = keypair.Value; locatedzone = true; break; } } if (!locatedzone) { // Boot up a zone foreach (KeyValuePair <string, ActiveZoneServer> keypair in _activezoneservers) { if (keypair.Value.zonename.Equals("inactivezoneserver")) { NetworkServer.SendToClient(keypair.Value.connid, EverMsgType.ZoneServerWorldChangeSceneRequest, new StringMessage()); ActiveZoneServer activezoneserver = new ActiveZoneServer(); activezoneserver = keypair.Value; activezoneserver.zonename = zonename; _pendinguserzonebootup[connectionid] = activezoneserver; break; } } } else { NetworkServer.SendToClient(connectionid, EverMsgType.WorldServerUserConnectionResponse, new StringMessage(BuildConnectionRequestResponse(false, targetzoneserver.hostname, targetzoneserver.port))); } }