Ejemplo n.º 1
0
    public void RpcAll(IMessagePacket _imp)
    {
        //_imp.fromIP = "HOST";
        //_imp.toIP = "ALL";
        string data = JsonUtility.ToJson(_imp);

        for (int i = 0; i < mAllClients.Count; i++)
        {
            mAllClients[i].Send(data);
        }
    }
Ejemplo n.º 2
0
        private void OnMsgReceivedByServer(string _imp)
        {
            Debug.Log("Server received :: " + _imp);
            //TODO:: here we can do all sorts of stuff like routing, security, p2p talks etc
            IMessagePacket imp = JsonUtility.FromJson <IMessagePacket> (_imp);

            //here we are routing only via msg type bcz it wont be a good idea to let the client "execute" command of server.
            //the idea here is that client can only request something, the processing of the request is upto server
            if (imp.msgType == MessageType.SIMPLE_MSG)
            {
                Debug.Log("SIMPLE_MSG passing to all clients");
                mMainServer.RpcAll(new MethodPacket("PassMessage", _imp).GetObject());
            }
            else
            {
                mMainServer.RpcAll(_imp);  // NOT A GOOD IDEA OFCOURSE, me just being lazy ?:?
            }
        }