public PotentialPlayer(Game _g, TcpClient _s, NetworkStream _ns, x1eJOINREQUEST jr) { game = _g; socket = _s; networkStream = _ns; joinReq = jr; }
public async void handleNewClient(TcpClient c) { NetworkStream ns = c.GetStream(); byte[] buf = new byte[1024]; ns.Read(buf, 0, buf.Length); if (buf[0] != 0xF7 || buf[1] != 0x1e) { c.Close(); return; } using (BinaryReader br = new BinaryReader(new MemoryStream(buf.Skip(4).ToArray()))){ x1eJOINREQUEST jr = (x1eJOINREQUEST)(new x1eJOINREQUEST().parse(br, 0)); //We can send len=0 here because the packet's parse function does not use the len. PotentialPlayer pp = new PotentialPlayer(this, c, ns, jr); if (isValidJr(jr)) { this.potentialPlayers.Add(pp); Console.WriteLine("Now have " + this.potentialPlayers.Count() + " total pps..."); Console.WriteLine("PP sent Valid JR, adding to list of pps"); } else { pp.rejectJoin((int)REJECTJOIN.WRONGPASSWD); //idk man seems right c.Close(); } } await Task.Yield(); }
public static void initTCP() { packets[0x01] = new x01PINGFROMHOST(); packets[0x04] = new x04SLOTINFOJOIN(); packets[0x05] = new x05REJECTJOIN(); packets[0x06] = new x06PLAYERINFO(); packets[0x07] = new x07PLAYERLEAVE(); packets[0x08] = new x08OTHERGAMELOADED(); packets[0x09] = new x09SLOTINFO(); packets[0x0A] = new x0aCOUNTDOWNSTART(); packets[0x0B] = new x0bCOUNTDOWNEND(); packets[0x0c] = new x0cACTIONBROADCAST(); packets[0x0F] = new x0fCHATFROMHOST(); packets[0x1E] = new x1eJOINREQUEST(); packets[0x21] = new x21PLAYERLEAVEREQ(); packets[0x23] = new x23OWNGAMELOADED(); packets[0x26] = new x26CLIENTACTION(); packets[0x27] = new x27CLIENTKEEPALIVE(); packets[0x28] = new x28CHATTOHOST(); packets[0x3d] = new x3dMAPCHECK(); packets[0x42] = new x42MAPSIZEVERIFY(); packets[0x46] = new x46PONGTOHOST(); packets[0x48] = new x48EXTRAACTIONBROADCAST(); }
public bool isValidJr(x1eJOINREQUEST jr) { Console.WriteLine("Received JoinRequest from " + jr.name + " at " + jr.iip + ":" + jr.port + "."); return(jr.gameId == this.id //jr.entryKey == keymap[jr.iip] && jr.name.Length > 0 && jr.name.Length <= 15 ); }