public static void SendAssigned(WorldConnection wc) { using (var p = new InterPacket(InterHeader.ASSIGNED)) { wc.SendPacket(p); } }
public static void HandleServerAssignement(WorldConnection wc, InterPacket packet) { byte wid; string name, ip; ushort port; if (!packet.TryReadByte(out wid) || !packet.TryReadString(out name) || !packet.TryReadString(out ip) || !packet.TryReadUShort(out port)) { Log.WriteLine(LogLevel.Error, "Could not read World ID in inter server packet."); wc.Disconnect(); return; } if (WorldManager.Instance.Worlds.ContainsKey(wid)) { Log.WriteLine(LogLevel.Error, "Already loaded this world?"); wc.Disconnect(); return; } wc.Name = name; wc.ID = wid; wc.IP = ip; wc.Port = port; wc.IsAWorld = true; if (WorldManager.Instance.Worlds.TryAdd(wc.ID, wc)) { Log.WriteLine(LogLevel.Info, "Assigned world {0}!", wc.ID); SendAssigned(wc); } else { Log.WriteLine(LogLevel.Error, "Couldn't assign world {0}..", wc.ID); } }
private static void SendWorldServerIP(LoginClient pClient, WorldConnection wc, string hash) { using (var pack = new Packet(SH3Type.WorldServerIP)) { pack.WriteByte((byte)wc.Status); string ip = pClient.Host == "127.0.0.1" ? "127.0.0.1" : wc.IP; pack.WriteString(wc.IP, 16); pack.WriteUShort(wc.Port); pack.WriteString(hash, 64); pClient.SendPacket(pack); } }
private void WorldAcceptor_OnIncommingConnection(Socket session) { // So something with it X: Log.WriteLine(LogLevel.Info, "Incoming connection from {0}", session.RemoteEndPoint); WorldConnection wc = new WorldConnection(session); }