public bool EnterWorld(NetIncomingMessage inc, out NetOutgoingMessage message, out string username) { message = server.CreateMessage(); username = null; if (inc.SenderConnection.RemoteHailMessage != null) { // Read opcode GameMessageTypes opcode = (GameMessageTypes)inc.SenderConnection.RemoteHailMessage.ReadByte(); if (opcode != GameMessageTypes.HandShake) { return(false); } HandShakeMessage msg = new HandShakeMessage(inc.SenderConnection.RemoteHailMessage); if (msg.Version == PacketHandler.PROTOCOL_VERSION && msg.Username != null && msg.Username.Length != 0) { username = msg.Username; return(true); } } return(false); //new UpdatePlayerStateMessage(this.playerManager.AddPlayer(false)).Encode(hailMessage); }
public void Connect() { if (gameServer != null) { connected = true; //Attempt to connect to the remote server NetOutgoingMessage om = client.CreateMessage(); IGameMessage gameMessage = new HandShakeMessage { Version = PacketHandler.PROTOCOL_VERSION, Username = Entry.Username }; om.Write((byte)gameMessage.MessageType); gameMessage.Encode(om); client.Connect(gameServer, om); } }