Beispiel #1
0
    //---------------------------------------------------------------------
    public void send(ushort method_id, byte[] data)
    {
        ushort data_len = 0;

        byte[] send_buf = null;
        if (data == null)
        {
            data_len = sizeof(ushort);
            send_buf = new byte[sizeof(ushort) + data_len];
        }
        else
        {
            data_len = (ushort)(sizeof(ushort) + data.Length);
            send_buf = new byte[sizeof(ushort) + data_len];
        }
        Array.Copy(BitConverter.GetBytes(data_len), 0, send_buf, 0, sizeof(ushort));
        Array.Copy(BitConverter.GetBytes(method_id), 0, send_buf, sizeof(ushort), sizeof(ushort));
        if (data != null && data.Length > 0)
        {
            Array.Copy(data, 0, send_buf, sizeof(ushort) * 2, data.Length);
        }
        mSession.send(send_buf);
    }