/// <summary>Sends the client into the game and informs other clients of the new player.</summary> /// <param name="_playerName">The username of the new player.</param> public void SendIntoGame(string _playerName) { PlayerHandler player = new PlayerHandler(id, _playerName); GameManager.Get.AddPlayer(id, player); // Send all players to the new player foreach (PlayerHandler p in GameManager.Get.Players.Values) { if (p.id != id) { PacketSender.SpawnPlayer(id, p); } } // Send the new player to all players (including himself) foreach (ClientConnection _client in Server.clients.Values) { PacketSender.SpawnPlayer(_client.id, player); } }
public virtual void OnAccept(IAsyncResult ar) { try { Socket newSocket = listenSocket.EndAccept(ar); if (newSocket != null) { PlayerHandler newClient = new PlayerHandler(newSocket, new RemoveClientDelegate(this.RemoveClient)); clients.Add(newClient); newClient.Start(); } } catch {} try { listenSocket.BeginAccept(new AsyncCallback(this.OnAccept), listenSocket); } catch { Dispose(); } }
public virtual void OnAccept( IAsyncResult ar ) { try { Socket newSocket = listenSocket.EndAccept( ar ); if ( newSocket != null ) { PlayerHandler newClient = new PlayerHandler( newSocket, new RemoveClientDelegate( this.RemoveClient ) ); clients.Add( newClient ); newClient.Start(); } } catch {} try { listenSocket.BeginAccept( new AsyncCallback( this.OnAccept ), listenSocket ); } catch { Dispose(); } }
public void ItemsUpdateForOther( PlayerHandler ph ) { int t = 0;// all.Count; foreach( Item i in Items ) if ( i != null ) t++; int offset = 4; Converter.ToBytes( (short)1, tempBuff, ref offset ); Converter.ToBytes( (int)0, tempBuff, ref offset ); Converter.ToBytes( Guid, tempBuff, ref offset ); ResetBitmap(); int pos = 0; int last = 1; for( pos = 0;pos < 19;pos++) { Item i = Items[ pos ]; if ( i != null ) { setUpdateValue( (int)UpdateFields.PLAYER_VISIBLE_ITEM_1_0 + pos * 12, i.Id ); } else setUpdateValue( (int)UpdateFields.PLAYER_VISIBLE_ITEM_1_0 + pos * 12, 0 ); } pos = 0; for(int j = 0;j < 19;j++ ) { Item i = Items[ j ]; if ( i != null ) { setUpdateValue( last = (int)UpdateFields.PLAYER_FIELD_INV_SLOT_HEAD + ( 2 * pos ), i.Guid ); } pos++; } FlushUpdateData( tempBuff, ref offset, 1 + ( last / 32 ) ); ph.Send( 0xA9, tempBuff, offset ); return; }
public DelaySend( PlayerHandler ph ) : base(WowTimer.Priorities.Milisec100 , 300, "DelaySend") { playerHangler = ph; Start(); }
public UpdateTimer( PlayerHandler ph, Character lc ) : base(WowTimer.Priorities.Milisec10 , 50, "UpdateTimer") { playerHangler = ph; loggedChar = lc; Start(); }
public void MovementHeartBeat( PlayerHandler ph, Character from ) { if ( true ) {/* byte []movePacket = { 0x00, 0x33, 0xDD, 0x00, 0x52, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6A, 0xFC, 0x3A, 0xC4, 0x7C, 0xBD, 0x96, 0xC5, 0x8B, 0x9D, 0xA0, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF6, 0x06, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x16, 0xE4, 0x39, 0xC4, 0x71, 0xBB, 0x96, 0xC5, 0xD2, 0xE5, 0xA6, 0x41}; */ byte []movePacket = { 0,0,0,0, 0xD1, 0x1C, 0x25, 0x00, 0x00, 0xA0, 0x00, 0xF0, 0x50, 0x45, 0xD4, 0xC3, 0x26, 0xDE, 0x21, 0xC5, 0x79, 0xCF, 0xBF, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x45, 0xD4, 0xC3, 0x26, 0xDE, 0x21, 0xC5, 0x79, 0xCF, 0xBF, 0x42 }; int offset = 4; Converter.ToBytes( Guid, movePacket, ref offset ); Converter.ToBytes( (float)from.X, movePacket, ref offset );// X Converter.ToBytes( (float)from.Y, movePacket, ref offset );// Y Converter.ToBytes( (float)from.Z, movePacket, ref offset );// Z Converter.ToBytes( (int)0, movePacket, ref offset );// Z Converter.ToBytes( (int)0, movePacket, ref offset );// Z Converter.ToBytes( (byte)0, movePacket, ref offset );// Z Converter.ToBytes( (int)0x23F, movePacket, ref offset );// Z Converter.ToBytes( (int)1, movePacket, ref offset );// Z Converter.ToBytes( (float)from.X + 20, movePacket, ref offset );// X Converter.ToBytes( (float)from.Y, movePacket, ref offset );// Y Converter.ToBytes( (float)from.Z, movePacket, ref offset );// Z ph.Send( 0xDD, movePacket, offset ); } }
public void AddPlayer(Guid id, PlayerHandler player) { Players.Add(id, player); }