Exemple #1
0
    Action send_action(Custom_msg_type _type, int actor, int recipient, int channel_id, int host_id, string name = "")
    {
        byte[]      data = new byte[2048];
        Message_obj msg  = new Message_obj();

        msg.target_connection = actor;
        if (!(_type == Custom_msg_type.CREATE_PLAYER || _type == Custom_msg_type.LOGIN ||
              _type == Custom_msg_type.ADD_FRIEND) && name == "")
        {
            msg.arg1 = pm.get_name(actor); //arg2 could be a custom message?
        }
        else
        {
            msg.arg1 = name;
        }
        print($"sending message of {msg.arg1} to {recipient} with type {_type}");
        Message_package msg_p = new Message_package();

        msg_p.type    = _type;
        msg_p.message = msg;
        data          = format_data(msg_p);
        byte error = (byte)0;

        return(() =>
               { NetworkTransport.Send(host_id, recipient, channel_id, data, data.Length, out error); print((NetworkError)error); });
    }
Exemple #2
0
    Action send_action(Custom_msg_type _type, int actor, int recipient, int channel_id, int host_id)
    {
        byte[]      data = new byte[1024];
        Message_obj msg  = new Message_obj();

        msg.target_connection = actor;
        msg.arg1 = pm.get_name(actor); //arg2 could be a custom message?
        Message_package msg_p = new Message_package();

        msg_p.type    = _type;
        msg_p.message = msg;
        data          = format_data(msg_p);
        byte error = (byte)0;

        return(() => NetworkTransport.Send(host_id, recipient, channel_id, data, data.Length, out error));
    }