public void Serialize(ByteStreamWriter writer) { writer.WriteInteger(id); int changeMask = 0; if (healthDirty) { changeMask = changeMask | maskOfHealthChange; } if (positionDirty) { changeMask = changeMask | maskOfPositionChange; } writer.WriteByte((byte)changeMask); if (healthDirty) { writer.WriteFloat(power); } if (positionDirty) { writer.WriteVector2(position); } }
public Vector2 m_point; //only when server sends public override void Serialize(ByteStreamWriter writer) { base.Serialize(writer); writer.WriteInteger(m_who); writer.WriteVector2(m_direction); writer.WriteVector2(m_point); }
public override void Serialize(ByteStreamWriter writer) { writer.WriteInteger(states.Count); foreach (PlayerState playerState in states) { playerState.Serialize(writer); } }
public override void Serialize(ByteStreamWriter writer) { writer.WriteInteger(m_sessionId); writer.WriteBool(m_actuallySpawned); if (m_actuallySpawned) { writer.WriteVector2(m_startPosition); } }
/// <summary> /// Starts handshake process. /// </summary> /// <param name="receivePort">The port server should send data to.</param> public void HandshakeStepOne(int receivePort) { ByteStreamWriter writer = new ByteStreamWriter(); writer.WriteByte((byte)MsgFlags.ConnectionRequest); writer.WriteByte((byte)HandshakeMessage.SYN); writer.WriteInteger(receivePort); m_sender.Send(writer.GetBytes()); State = ConnectionState.Connecting; }
private void HandshakeStepTwo(BaseConnectionEntity con) { ByteStreamWriter writer = new ByteStreamWriter(); writer.WriteByte((byte)MsgFlags.ConnectionRequest); writer.WriteByte((byte)HandshakeMessage.SYNACK); writer.WriteInteger(con.m_connectionId); con.m_sender.Send(writer.GetBytes()); con.m_sender.Send(writer.GetBytes()); con.m_sender.Send(writer.GetBytes()); con.m_sender.Send(writer.GetBytes()); }
public void Shutdown() { ByteStreamWriter writer = new ByteStreamWriter(); writer.WriteByte((byte)MsgFlags.ConnectionRequest); writer.WriteByte((byte)HandshakeMessage.Disconnect); writer.WriteInteger(ConnectionId); for (int i = 0; i < 5; ++i) { Send(writer); } m_client.Shutdown(); }
/// <summary> /// Sends a confirmation of receiving the Connection ID to server (finalizes the connection on the Client side) /// </summary> /// <param name="connectionId">The connection identifier.</param> public void HandshakeStepThree(int connectionId) { ByteStreamWriter writer = new ByteStreamWriter(); writer.WriteByte((byte)MsgFlags.ConnectionRequest); writer.WriteByte((byte)HandshakeMessage.ACK); writer.WriteInteger(connectionId); for (int i = 0; i < 5; ++i) { m_sender.Send(writer.GetBytes()); } ConnectionId = connectionId; State = ConnectionState.Connected; Network.Log(State + ", " + ConnectionId); }
public override void Serialize(ByteStreamWriter writer) { writer.WriteInteger(m_reliableEventId); }
public override void Serialize(ByteStreamWriter writer) { writer.WriteVector2(m_direction); writer.WriteInteger(m_sessionId); }