Esempio n. 1
0
    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);
        }
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
 public override void Serialize(ByteStreamWriter writer)
 {
     writer.WriteInteger(states.Count);
     foreach (PlayerState playerState in states)
     {
         playerState.Serialize(writer);
     }
 }
Esempio n. 4
0
 public override void Serialize(ByteStreamWriter writer)
 {
     writer.WriteInteger(m_sessionId);
     writer.WriteBool(m_actuallySpawned);
     if (m_actuallySpawned)
     {
         writer.WriteVector2(m_startPosition);
     }
 }
Esempio n. 5
0
    /// <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;
    }
Esempio n. 6
0
    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());
    }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
    /// <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);
    }
Esempio n. 9
0
 public override void Serialize(ByteStreamWriter writer)
 {
     writer.WriteInteger(m_reliableEventId);
 }
Esempio n. 10
0
 public override void Serialize(ByteStreamWriter writer)
 {
     writer.WriteVector2(m_direction);
     writer.WriteInteger(m_sessionId);
 }