Beispiel #1
0
    public void sendClientToServer(iNwkMessage message, bool reliable = true)
    {
        Debug.Assert(message != null, "no message given ?");

        //bool silent = false;
        //NwkMessageFull mFull = message as NwkMessageFull;
        //if (mFull != null) silent = mFull.isSilent();

        string        sId = "";
        iNwkMessageId id  = message as iNwkMessageId;

        if (id != null)
        {
            sId = id.getIdCard().getMessageSender() + "<>" + id.getIdCard().getMessageType();
        }

        //NwkSystemBase.nwkSys.log("<b>sending "+message.GetType()+"</b> "+ sId, message.isSilent());

        Debug.Assert((message as MessageBase) != null, "can't cast message to unet type ?");
        if (!reliable)
        {
            //0 is reliable, 1 unreliable
            unetClient.SendByChannel(message.getMessageUnetId(), message as MessageBase, 1);
        }
        else
        {
            unetClient.Send(message.getMessageUnetId(), message as MessageBase);
        }
    }
Beispiel #2
0
 /// <summary>
 /// SERVER
 /// bridge to broadcast message to everyone
 /// only for server
 ///
 /// senderUid can be different if trying to forward some data from a client to all other clients
 /// </summary>
 public void broadcastServerToAll(iNwkMessageId message, int senderUid = 0)
 {
     message.getIdCard().setMessageSender(senderUid);
     NetworkServer.SendToAll(message.getMessageUnetId(), message as MessageBase);
 }
Beispiel #3
0
 /// <summary>
 /// SERVER
 /// this function needs to provide the client connection id
 /// </summary>
 public void sendToSpecificClient(iNwkMessageId message, int clientConnectionId)
 {
     NetworkServer.SendToClient(clientConnectionId, message.getMessageUnetId(), message as MessageBase);
 }