public void Btn_SendMsg()
    {
        SendToClientPara stcp = new SendToClientPara()
        {
            RecvType       = RecvType.RoomAll,
            Msg            = "123",
            RecvPlayerList = new List <string>(),
        };

        paintRoom.SendToClient(stcp, eve =>
        {
        });
    }
Beispiel #2
0
    public void OnReady()
    {
        var recvList = new List <string>();

        foreach (var playerInfo in room.RoomInfo.PlayerList)
        {
            recvList.Add(playerInfo.Id);
        }
        var send = new SendToClientPara()
        {
            Msg            = "Hello World",
            RecvType       = RecvType.RoomAll,
            RecvPlayerList = recvList,
        };

        room.SendToClient(send, evt =>
        {
            Debug.Log(evt.Code);
        });
    }
Beispiel #3
0
        public void SendToClient(SendToClientPara para, Action <ResponseEvent> callback)
        {
            var recvPlayerList = para.RecvPlayerList;

            switch (para.RecvType)
            {
            case RecvType.RoomAll:
            {
                // 发给所有玩家
                recvPlayerList.AddRange(RoomInfo.PlayerList.Select(info => info.Id));
                break;
            }

            case RecvType.RoomOthers:
            {
                // 不包含自己的其他玩家
                recvPlayerList.AddRange(from info in RoomInfo.PlayerList where !info.Id.Equals(RequestHeader.PlayerId) select info.Id);
                break;
            }

            case RecvType.RoomSome:
                break;

            default:
            {
                callback?.Invoke(new ResponseEvent(ErrCode.EcParamsInvalid, "参数错误,消息接收者类型无效", "", null));
                return;
            }
            }
            var callbackPara = new SendToClientPara {
                RecvPlayerList = recvPlayerList,
                Msg            = para.Msg
            };

            Sdk.SendToClient(para, RoomInfo.Id, callback);
        }