Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        buff_handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
        buff_ptr    = GCHandle.ToIntPtr(buff_handle);

        PacketHeader header;

        header.nodeSource = 42;
        header.type       = MessageType.PING;
        SetNodeID sni;

        sni.Header = header;
        sni.NET_ID = 69;
        byte[]       bytes        = NetEngine.GetBytes <SetNodeID>(sni);
        PacketHeader deserialized = NetEngine.ByteArrayToStructure <PacketHeader>(bytes);

        Debug.Log(deserialized.nodeSource);
        Debug.Log(deserialized.type.ToString());
        SetNodeID sni_des = NetEngine.ByteArrayToStructure <SetNodeID>(bytes);

        Debug.Log(sni_des.NET_ID);
        Debug.Log(Marshal.SizeOf(sni_des));

        Buffer.BlockCopy(bytes, 0, buffer, 0, Marshal.SizeOf(sni_des));

        SetNodeID sni_des2 = NetEngine.ByteArrayToStructure <SetNodeID>(buffer);

        Debug.Log(sni_des2.NET_ID);
        Debug.Log(Marshal.SizeOf(sni_des2));
    }
Exemplo n.º 2
0
    public void RecvSetNetID(int hostId, int connectionId, int channelId, byte[] buffer, int bufferSize, int recieved, byte error)
    {
        if (is_server)
        {
            Debug.LogWarning("Some idiot's trying to set server id");
            return;
        }
        SetNodeID sni = ByteArrayToStructure <SetNodeID>(buffer);

        this.node_id = sni.NET_ID;
        Debug.Log("Recieved Authoratative Net_Id: " + sni.NET_ID);
    }