public void SendTo(byte[] data, ushort reciver)
        {
            if (Channel == MessageChannel.Unsafe && data.Length != MAX_UNSAFE_PACKAGE_SIZE)
            {
                throw new ArgumentException("The passed array must be " + MAX_UNSAFE_PACKAGE_SIZE + " long if the channel is set to unsafe", nameof(data));
            }

            byte[] msg = createFullMsg(FullMessageID, data);

            if (NetworkingCore.CurrentClientType == ClientType.Client)
            {
                throw new Exception("Cannot send data to a reciver from a client");
            }
            else if (NetworkingCore.CurrentClientType == ClientType.Host)
            {
                if (Channel == MessageChannel.Safe)
                {
                    if (reciver == 0)                    // if the target is the server, just run the function locally
                    {
                        NetworkingCore.ScheduleForMainThread(delegate
                        {
                            OnPackageReceivedClient(data);
                        });
                    }
                    else
                    {
                        NetworkingCore.SendServerTcpMessage(msg, reciver);
                    }
                }
                else if (Channel == MessageChannel.Unsafe)
                {
                    if (reciver == 0)                    // if the target is the server, just run the function locally
                    {
                        NetworkingCore.ScheduleForMainThread(delegate
                        {
                            OnPackageReceivedClient(data);
                        });
                    }
                    else
                    {
                        NetworkingCore.SendServerUdpMessage(msg, reciver);
                    }
                }
            }
        }
        public void Send(byte[] data)
        {
            if (Channel == MessageChannel.Unsafe && data.Length != MAX_UNSAFE_PACKAGE_SIZE)
            {
                throw new ArgumentException("The passed array must be " + MAX_UNSAFE_PACKAGE_SIZE + " long if the channel is set to unsafe", nameof(data));
            }

            byte[] msg = createFullMsg(FullMessageID, data);

            if (NetworkingCore.CurrentClientType == ClientType.Client)
            {
                if (Channel == MessageChannel.Safe)
                {
                    NetworkingCore.SendClientTcpMessage(msg);
                }
                else if (Channel == MessageChannel.Unsafe)
                {
                    NetworkingCore.SendClientUdpMessage(msg);
                }
            }
            else if (NetworkingCore.CurrentClientType == ClientType.Host)
            {
                if (Channel == MessageChannel.Safe)
                {
                    NetworkingCore.ScheduleForMainThread(delegate
                    {
                        OnPackageReceivedClient(data);                         // since the server is itself kind of a client we call on received client locally too
                    });
                    NetworkingCore.SendServerTcpMessage(msg);
                }
                else if (Channel == MessageChannel.Unsafe)
                {
                    NetworkingCore.ScheduleForMainThread(delegate
                    {
                        OnPackageReceivedClient(data);                         // since the server is itself kind of a client we call on received client locally too
                    });
                    NetworkingCore.SendServerUdpMessage(msg);
                }
            }
        }