コード例 #1
0
            internal ServerPacket Packet()
            {
                ServerPacket packet   = new ServerPacket(OpCode);
                int          position = packet.Position;

                packet.WriteUInt32(TargetId);
                packet.WriteUInt32(SourceId ?? 0);
                packet.WriteUInt16((ushort)TargetAnimation);
                packet.WriteUInt16((ushort)(SourceAnimation ?? 0));
                packet.WriteInt16(Speed);
                packet.WriteInt32(0);
                return(packet);
            }
コード例 #2
0
ファイル: Client.cs プロジェクト: wren11/server
        /// <summary>
        /// Atomically update the tick-based (0x68) heartbeat values and transmit
        /// it to the client.
        /// </summary>
        public void SendTickHeartbeat()
        {
            var aliveSince = new TimeSpan(DateTime.Now.Ticks - ConnectedSince);

            if (aliveSince.TotalSeconds < Constants.BYTE_HEARTBEAT_INTERVAL)
            {
                return;
            }
            var tickHeartbeat = new ServerPacket(0x68);
            // We never really want to deal with negative values
            var tickCount = Environment.TickCount & Int32.MaxValue;

            Interlocked.Exchange(ref _localTickCount, tickCount);
            tickHeartbeat.WriteInt32(tickCount);
            Enqueue(tickHeartbeat);
            Interlocked.Exchange(ref _tickHeartbeatSent, DateTime.Now.Ticks);
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: DomGrieco/server
 /// <summary>
 /// Atomically update the tick-based (0x68) heartbeat values and transmit
 /// it to the client.
 /// </summary>
 public void SendTickHeartbeat()
 {
     var aliveSince = new TimeSpan(DateTime.Now.Ticks - ConnectedSince);
     if (aliveSince.TotalSeconds < Constants.BYTE_HEARTBEAT_INTERVAL)
         return;
     var tickHeartbeat = new ServerPacket(0x68);
     // We never really want to deal with negative values
     var tickCount = Environment.TickCount & Int32.MaxValue;
     Interlocked.Exchange(ref _localTickCount, tickCount);
     tickHeartbeat.WriteInt32(tickCount);
     Enqueue(tickHeartbeat);
     Interlocked.Exchange(ref _tickHeartbeatSent, DateTime.Now.Ticks);
 }