//---------------------------------------------------------------------
    public Task c2sSendDesktopChat(ChatMsgRecv msg_recv)
    {
        if (!string.IsNullOrEmpty(DesktopEtGuid))
        {
            var grain         = Entity.getUserData <GrainCellPlayer>();
            var grain_desktop = grain.GF.GetGrain <ICellDesktop>(new Guid(DesktopEtGuid));
            grain_desktop.s2sDesktopChat(msg_recv);
        }

        return(TaskDone.Done);
    }
Example #2
0
    //-------------------------------------------------------------------------
    void _s2cChatMsg(ChatMsgRecv msg_recv)
    {
        PlayerChatNotify playerchat_notify;

        playerchat_notify.id   = PlayerChatNotifyId.RecvChatMsg;
        playerchat_notify.data = EbTool.protobufSerialize <ChatMsgRecv>(msg_recv);

        MethodData method_data = new MethodData();

        method_data.method_id = MethodType.s2cPlayerChatNotify;
        method_data.param1    = EbTool.protobufSerialize <PlayerChatNotify>(playerchat_notify);
        var grain        = Entity.getUserData <GrainCellPlayer>();
        var grain_player = grain.GF.GetGrain <ICellPlayer>(new Guid(Entity.Guid));

        grain_player.s2sNotify(method_data);
    }
Example #3
0
    //---------------------------------------------------------------------
    // 桌子内聊天广播
    public Task s2sDesktopChat(ChatMsgRecv msg)
    {
        DesktopNotify desktop_notify;

        desktop_notify.id   = DesktopNotifyId.PlayerChat;
        desktop_notify.data = EbTool.protobufSerialize <ChatMsgRecv>(msg);

        StreamData sd = new StreamData();

        sd.event_id = StreamEventId.DesktopStreamEvent;
        sd.param1   = desktop_notify;
        var grain_desktop = Entity.getUserData <GrainCellDesktop>();

        grain_desktop.AsyncStream.OnNextAsync(sd);

        return(TaskDone.Done);
    }
Example #4
0
    //-------------------------------------------------------------------------
    public Task <MethodData> c2sPlayerChatRequest(MethodData method_data)
    {
        MethodData result = new MethodData();

        result.method_id = MethodType.None;

        var playerchat_request = EbTool.protobufDeserialize <PlayerChatRequest>(method_data.param1);

        switch (playerchat_request.id)
        {
        case PlayerChatRequestId.SendChatMsg:
        {
            var msg = EbTool.protobufDeserialize <ChatMsgSend>(playerchat_request.data);

            switch (msg.chat_type)
            {
            case ChatType.Desktop:            // 牌桌中聊天广播
            {
                ChatMsgRecv msg_recv = new ChatMsgRecv();
                msg_recv.chat_type           = msg.chat_type;
                msg_recv.is_emotion          = msg.is_emotion;
                msg_recv.content             = msg.content;
                msg_recv.et_player_guid_recv = msg.et_player_guid_recv;
                msg_recv.et_player_guid_send = Entity.Guid;
                msg_recv.dt = DateTime.Now;

                CoPlayer.CoPlayerDesktop.c2sSendDesktopChat(msg_recv);
            }
            break;

            case ChatType.Friend:            // 好友聊天
            {
                // 返回给自己
                ChatMsgRecv msg_recv = new ChatMsgRecv();
                msg_recv.chat_type           = msg.chat_type;
                msg_recv.is_emotion          = msg.is_emotion;
                msg_recv.content             = msg.content;
                msg_recv.et_player_guid_recv = msg.et_player_guid_recv;
                msg_recv.et_player_guid_send = Entity.Guid;
                msg_recv.dt = DateTime.Now;

                // 发送给好友
                var grain             = Entity.getUserData <GrainCellPlayer>();
                var grain_playerproxy = grain.GF.GetGrain <ICellPlayerProxy>(new Guid(msg.et_player_guid_recv));
                grain_playerproxy.s2sRecvChatFromFriend(msg_recv);

                _s2cChatMsg(msg_recv);
            }
            break;

            default:
                break;
            }
        }
        break;

        default:
            break;
        }

        return(Task.FromResult(result));
    }
Example #5
0
    //---------------------------------------------------------------------
    // 桌内聊天
    public Task s2sRecvChatFromDesktop(ChatMsgRecv msg_recv)
    {
        _s2cChatMsg(msg_recv);

        return(TaskDone.Done);
    }
Example #6
0
    //---------------------------------------------------------------------
    // 好友聊天
    public Task s2sProxyRecvChatFromFriend(ChatMsgRecv msg_recv)
    {
        _s2cChatMsg(msg_recv);

        return(TaskDone.Done);
    }
Example #7
0
    //-------------------------------------------------------------------------
    // 收到玩家本人Couchbase队列中的消息
    public async Task recvCouchbaseQueData(CouchbaseQueData que_data)
    {
        CouchbaseQueDataType que_data_type = (CouchbaseQueDataType)que_data.type;

        EbLog.Note("CellPlayer.recvCouchbaseQueData() DataType=" + que_data_type);
        switch (que_data_type)
        {
        case CouchbaseQueDataType.InvitePlayerEnterDesktop:    // 收到好友进桌邀请
        {
            string from_friend_etguid = que_data.map_data["from_friend_etguid"];
            string desktop_etguid     = que_data.map_data["desktop_etguid"];
            int    sb         = int.Parse(que_data.map_data["sb"]);
            int    bb         = int.Parse(que_data.map_data["bb"]);
            int    player_num = int.Parse(que_data.map_data["player_num"]);
            int    seat_num   = int.Parse(que_data.map_data["seat_num"]);

            var grain = Entity.getUserData <GrainCellPlayer>();
            var grain_playerservice = grain.GF.GetGrain <ICellPlayerService>(0);
            var player_info         = await grain_playerservice.getPlayerInfo(from_friend_etguid);

            s2sProxyInvitePlayerEnterDesktop(player_info, desktop_etguid, sb, bb, player_num, seat_num);
        }
        break;

        case CouchbaseQueDataType.GivePlayerChip:    // 收到玩家赠送的筹码
        {
            string from_player_etguid = que_data.map_data["from_player_etguid"];
            int    chip = int.Parse(que_data.map_data["chip"]);

            var grain = Entity.getUserData <GrainCellPlayer>();
            var grain_playerservice = grain.GF.GetGrain <ICellPlayerService>(0);
            var player_info         = await grain_playerservice.getPlayerInfo(from_player_etguid);

            s2sProxyGivePlayerChip(player_info, chip);
        }
        break;

        case CouchbaseQueDataType.RequestAddFriend:    // 请求加好友
        {
            string request_player_etguid = que_data.map_data["request_player_etguid"];

            var grain = Entity.getUserData <GrainCellPlayer>();
            var grain_playerservice = grain.GF.GetGrain <ICellPlayerService>(0);
            var player_info         = await grain_playerservice.getPlayerInfo(request_player_etguid);

            var co_friend = Entity.getComponent <CellPlayerFriend <DefPlayerFriend> >();
            co_friend.s2sProxyRequestAddFriend(player_info);
        }
        break;

        case CouchbaseQueDataType.ResponseAddFriend:    // 响应加好友
        {
            string response_player_etguid = que_data.map_data["response_player_etguid"];
            bool   agree = bool.Parse(que_data.map_data["agree"]);

            var grain = Entity.getUserData <GrainCellPlayer>();
            var grain_playerservice = grain.GF.GetGrain <ICellPlayerService>(0);
            var player_info         = await grain_playerservice.getPlayerInfo(response_player_etguid);

            var co_friend = Entity.getComponent <CellPlayerFriend <DefPlayerFriend> >();
            co_friend.s2sProxyResponseAddFriend(player_info, agree);
        }
        break;

        case CouchbaseQueDataType.DeleteFriend:    // 删除好友
        {
            string friend_etguid = que_data.map_data["friend_etguid"];

            var co_friend = Entity.getComponent <CellPlayerFriend <DefPlayerFriend> >();
            co_friend.s2sProxyDeleteFriend(friend_etguid);
        }
        break;

        case CouchbaseQueDataType.RecvChatFromFriend:    // 好友聊天
        {
            string      s        = que_data.map_data["msg_recv"];
            ChatMsgRecv msg_recv = EbTool.jsonDeserialize <ChatMsgRecv>(s);

            var co_chat = Entity.getComponent <CellPlayerChat <DefPlayerChat> >();
            co_chat.s2sProxyRecvChatFromFriend(msg_recv);
        }
        break;

        case CouchbaseQueDataType.RecvMail:    // 收到邮件
        {
            string   s         = que_data.map_data["mail_data"];
            MailData mail_data = EbTool.jsonDeserialize <MailData>(s);

            var co_mailbox = Entity.getComponent <CellPlayerMailBox <DefPlayerMailBox> >();
            co_mailbox.s2sProxyRecvMail(mail_data);
        }
        break;

        default:
            break;
        }
    }