Exemplo n.º 1
0
    /// <summary>
    /// 发送礼物表情消息
    /// </summary>
    /// <param name="str">礼物字符串标注("int(语音号),int(发送方位)")</param>
    public void SendProp(string str)
    {
        string[] strs = str.Split(',');
        //GameObject  go =  Instantiate(Resources.Load<GameObject>("Game_GYMJ/Prefabs/prop/" + strs[0]), GameUIGO.transform.Find("Fixed_UI/Heads")) as GameObject;
        // go.GetComponent<RectTransform>().localPosition = GetHeadPos((int)(GameInfo.GetFW(GameInfo.FW)));
        //go.GetComponent<RectTransform>().localScale = Vector3.one;
        //go.GetComponent<Image>().SetNativeSize();
        // go.GetComponent<RectTransform>().DOLocalMove(GetHeadPos(int.Parse(strs[1])), 2);
        //StartCoroutine(PropMove(go));

        //SendVoice sendGameOperation = SendVoice.CreateBuilder()
        //   .SetOpenid(GameInfo.OpenID)
        //   .SetRoomID(GameInfo.room_id)
        //   .SetVoiceNumber(int.Parse(strs[0]))
        //   .SetFWT(GetTrueFw(int.Parse(strs[1])))
        //   .Build();
        //byte[] body = sendGameOperation.ToByteArray();

        SendVoice sendGameOperation = new SendVoice();

        sendGameOperation.openid      = GameInfo.OpenID;
        sendGameOperation.RoomID      = GameInfo.room_id;
        sendGameOperation.VoiceNumber = int.Parse(strs[0]);
        sendGameOperation.FWT         = GetTrueFw(int.Parse(strs[1]));
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendGameOperation);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 8002, body.Length, 0, body);
        Debug.Log(data);
        GameInfo.cs.Send(data);
    }
Exemplo n.º 2
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            if (!Gongyong.userlist.Any(w => w.session.SessionID.Equals(session.SessionID)))
            {
                session.Logger.Debug("ReqVoice : 非法连接");
                session.Close();
                return;
            }
            var  sendData = SendVoice.ParseFrom(requestInfo.Body);
            Room r        = Gongyong.roomlist.Find(u => u.RoomID == sendData.RoomID);

            if (r == null)
            {
                return;
            }
            var userList = Gongyong.mulist.FindAll(w => w.RoomID == sendData.RoomID);

            foreach (var item in userList)
            {
                var user  = Gongyong.userlist.FirstOrDefault(w => w.openid == item.Openid);
                var voice = ReturnVoice.CreateBuilder().SetFW(item.ZS_Fw).SetVoiceNumber(sendData.VoiceNumber);
                if (sendData.HasFWT)
                {
                    voice.SetFWT(sendData.FWT);
                }
                var data = voice.Build().ToByteArray();
                user.session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 8003, data.Length, requestInfo.MessageNum, data)));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///  回复的语音消息的函数
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="mediaId">服务器上语音的ID</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 10:25:01
 private static void ProduceVoice(Dictionary<string, string> model, int mediaId)
 {
     SendVoice voice = new SendVoice();
     voice.ToUserName = model.ReadKey(PublicField.FromUserName);
     voice.FromUserName = model.ReadKey(PublicField.ToUserName);
     voice.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     voice.MsgType = "voice";
     voice.MediaId = mediaId;
     OperateXml.ResponseEnd(Templete.SendVoice(voice));
 }
Exemplo n.º 4
0
 /// <summary>
 ///  回复语音消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-10 11:00:22
 public static string SendVoice(SendVoice model)
 {
     return(string.Format(@"<xml>
                             <ToUserName><![CDATA[{0}]]></ToUserName>
                             <FromUserName><![CDATA[{1}]]></FromUserName>
                             <CreateTime>{2}</CreateTime>
                             <MsgType><![CDATA[{3}]]></MsgType>
                             <Voice>
                                 <MediaId><![CDATA[{4}]]></MediaId>
                             </Voice>
                            </xml>", model.ToUserName, model.FromUserName, model.CreateTime, model.MsgType, model.MediaId));
 }
Exemplo n.º 5
0
    /// <summary>
    /// 发送播放选择的快捷语音
    /// </summary>
    public void SendQuickVoice(int voiceNum)
    {
        SendVoice sencGameOperation = new SendVoice();

        sencGameOperation.openid      = GameInfo.OpenID;
        sencGameOperation.RoomID      = GameInfo.room_id;
        sencGameOperation.VoiceNumber = voiceNum;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sencGameOperation);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 8002, body.Length, 0, body);
        Debug.Log(data);
        GameInfo.cs.Send(data);
        GameInfo.isScoketClose = true;
    }
 public static ValidationResult <SendVoice> CreateValidation(this SendVoice value) => new ValidationResult <SendVoice>(value)
 .ValidateRequired(x => x.ChatId)
 .ValidateRequired(x => x.Voice);