Exemplo n.º 1
0
        public void TestCallMessageParse()
        {
            String      str  = "{\"id\": 0, \"method\": \"blockchain.headers.subscribe\", \"params\": []}";
            CallMessage call = new CallMessage(str);

            Assert.AreEqual(call.Method, "blockchain.headers.subscribe");
        }
Exemplo n.º 2
0
    private void SuccesLogin(WWW www)
    {
        ServerController.onSuccessHandler -= SuccesLogin;
        ServerController.onSuccessHandler  = null;
        Models.user = JsonUtility.FromJson <Garage>(www.text);
        Debug.Log(www.text);
        Debug.Log(Models.user.user);
        LoginPage.SetActive(false);
        GlobalParameters.isLogined = true;
        if (isSaveble)
        {
            SaveModelController.SaweUserData();
        }
        if (!PlayerPrefs.HasKey("google"))
        {
            PlayerPrefs.SetInt("google", 0);
            var auth = new UnityGoogleDrive.Data.File()
            {
                Name = "authointification"
            };
            GoogleDriveFiles.Create(auth).Send();
        }
        CallMessage cmsg = new CallMessage();

        cmsg.from   = Models.user.user;
        cmsg.to     = SystemInfo.deviceUniqueIdentifier;
        cmsg.comand = "login";

        WEbSocketController.GetInstance.SendMessage(JsonUtility.ToJson(cmsg));
    }
Exemplo n.º 3
0
    IEnumerator WaytCorutine()
    {
        int time = 30;

        SoundController.GetInstance.playStartSound();
        while (time > 0)
        {
            text.text = time.ToString();
            yield return(new WaitForSeconds(1));

            time--;
        }
        SoundController.GetInstance.StopAll();

        CallMessage msg = new CallMessage();

        msg        = cmsg;
        msg.comand = "stop";
        string jline = JsonUtility.ToJson(msg);

        WEbSocketController.GetInstance.SendMessage(jline);

        poup.SetActive(true);
        text.gameObject.SetActive(false);
    }
Exemplo n.º 4
0
        /// <summary>
        /// 请求开始
        /// </summary>
        /// <param name="reqMsg"></param>
        internal static void BeginRequest(this IServiceLog logger, RequestMessage reqMsg)
        {
            if (logger == null)
            {
                return;
            }

            try
            {
                var callMsg = new CallMessage
                {
                    AppName     = reqMsg.AppName,
                    IPAddress   = reqMsg.IPAddress,
                    HostName    = reqMsg.HostName,
                    ServiceName = reqMsg.ServiceName,
                    MethodName  = reqMsg.MethodName,
                    Parameters  = reqMsg.Parameters
                };

                //开始调用
                logger.Begin(callMsg);
            }
            catch
            {
            }
        }
Exemplo n.º 5
0
    void OnNewMessage(Socket socket, Packet packet, params object[] args)
    {
        //addChatMessage();
        //data = args[0] as Dictionary<string, object>;
        string msg = args[0] as string;

        Debug.Log("socketio Geted : " + msg);
        if (string.IsNullOrEmpty(msg))
        {
            return;
        }

        CallMessage cmsg = JsonUtility.FromJson <CallMessage>(msg);

        if (cmsg.from.Equals(Models.user.user))
        {
            if (cmsg.comand.Equals("login"))
            {
                //Debug.Log(SystemInfo.deviceUniqueIdentifier + "  :  " + cmsg.to);
                if (!SystemInfo.deviceUniqueIdentifier.Equals(cmsg.to))
                {
                    cmsg.comand = "outlog";

                    SendMessage(JsonUtility.ToJson(cmsg));
                }
            }

            if (cmsg.comand.Equals("outlog"))
            {
                if (SystemInfo.deviceUniqueIdentifier.Equals(cmsg.to))
                {
                    GlobalParameters.isLogined = false;
                    PlayerPrefs.DeleteKey("user");
                    GlobalParameters.IsUserLogined = true;
                    SceneManager.LoadScene(0);
                }
            }
        }
        if (cmsg.to.Equals(Models.user.user))
        {
            if (cmsg.comand.Equals("busy"))
            {
                SoundController.GetInstance.playBisy();
                WaytForACallController.GetInstance.SetBusy();
            }
            if (cmsg.comand.Equals("accept"))
            {
                SoundController.GetInstance.StopAll();
                TestHome.GetInstance.onJoinButtonClicked(true);
            }
            if (cmsg.comand.Equals("reject"))
            {
                SoundController.GetInstance.playBisy();
                WaytForACallController.GetInstance.SetBusy();
            }
        }
    }
Exemplo n.º 6
0
        public void TestCallMessage()
        {
            CallMessage call = new CallMessage(1L, "blockchain.address.listunspent",
                                               new Object[] { "npF3ApeWwMS8kwXJyybPZ76vNbv5txVjDf" });

            Assert.AreEqual(call.Id, 1L);
            Assert.AreEqual(call.Method, "blockchain.address.listunspent");
            //Assert.AreEqual("{\"id\":1,\"method\":\"blockchain.address.listunspent\"," +
            //        "\"params\":[\"npF3ApeWwMS8kwXJyybPZ76vNbv5txVjDf\"]}", call.ToString());
        }
Exemplo n.º 7
0
 /// <summary>
 /// Creates na new <see cref="ProcedureContext"/> object used to schedule remote procedure call.
 /// </summary>
 /// <param name="message">Call message used for RPC request</param>
 /// <param name="definition">Definition of procedure to be called</param>
 /// <param name="session">WAMP message sender session object</param>
 /// <returns></returns>
 public virtual ProcedureContext CreateProcedureContext(CallMessage message, ProcedureDefinition definition, IWampSession session)
 {
     var procedureContext = new ProcedureContext
                                {
                                    Arguments = message.Arguments,
                                    CallId = message.CallId,
                                    ProcedureDefinition =  definition,
                                    RequesterSession = session
                                };
     return procedureContext;
 }
Exemplo n.º 8
0
        public void Subscibe(CallMessage call, SubscribeResult handler)
        {
            lock (this)
                call.Id = lastId++;

            sendToServer(call.ToString());

            var tcs = new TaskCompletionSource <ResultMessage>();

            lock (this)
                subscribes[call.Id] = handler;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates na new <see cref="ProcedureContext"/> object used to schedule remote procedure call.
        /// </summary>
        /// <param name="message">Call message used for RPC request</param>
        /// <param name="definition">Definition of procedure to be called</param>
        /// <param name="session">WAMP message sender session object</param>
        /// <returns></returns>
        public virtual ProcedureContext CreateProcedureContext(CallMessage message, ProcedureDefinition definition, IWampSession session)
        {
            var procedureContext = new ProcedureContext
            {
                Arguments           = message.Arguments,
                CallId              = message.CallId,
                ProcedureDefinition = definition,
                RequesterSession    = session
            };

            return(procedureContext);
        }
Exemplo n.º 10
0
        private byte[] CreateCallContent(SignalServiceCallMessage callMessage)
        {
            Content     content         = new Content();
            CallMessage pushCallMessage = new CallMessage();

            if (callMessage.OfferMessage != null)
            {
                pushCallMessage.Offer = new CallMessage.Types.Offer()
                {
                    Id          = callMessage.OfferMessage.Id,
                    Description = callMessage.OfferMessage.Description
                };
            }
            else if (callMessage.AnswerMessage != null)
            {
                pushCallMessage.Answer = new CallMessage.Types.Answer()
                {
                    Id          = callMessage.AnswerMessage.Id,
                    Description = callMessage.AnswerMessage.Description
                };
            }
            else if (callMessage.IceUpdateMessages != null)
            {
                foreach (IceUpdateMessage u in callMessage.IceUpdateMessages)
                {
                    pushCallMessage.IceUpdate.Add(new CallMessage.Types.IceUpdate()
                    {
                        Id            = u.Id,
                        Sdp           = u.Sdp,
                        SdpMid        = u.SdpMid,
                        SdpMLineIndex = u.SdpMLineIndex
                    });
                }
            }
            else if (callMessage.HangupMessage != null)
            {
                pushCallMessage.Hangup = new CallMessage.Types.Hangup()
                {
                    Id = callMessage.HangupMessage.Id
                };
            }
            else if (callMessage.BusyMessage != null)
            {
                pushCallMessage.Busy = new CallMessage.Types.Busy()
                {
                    Id = callMessage.BusyMessage.Id
                };
            }

            content.CallMessage = pushCallMessage;
            return(content.ToByteArray());
        }
Exemplo n.º 11
0
    public void DisActive()
    {
        parent.SetActive(false);
        SoundController.GetInstance.StopAll();
        StopCoroutine("WaytCorutine");
        CallMessage msg = new CallMessage();

        msg        = cmsg;
        msg.comand = "stop";
        string jline = JsonUtility.ToJson(msg);

        WEbSocketController.GetInstance.SendMessage(jline);
    }
Exemplo n.º 12
0
        public Task <ResultMessage> Call(CallMessage call)
        {
            lock (this)
                call.Id = lastId++;

            sendToServer(call.ToString());

            var tcs = new TaskCompletionSource <ResultMessage>();

            lock (this)
                callers[call.Id] = tcs;

            return(tcs.Task);
        }
Exemplo n.º 13
0
    private void SuccesLogin(WWW www)
    {
        Models.user = JsonUtility.FromJson <UserModel>(www.text);
        LoginPage.SetActive(false);
        GlobalParameters.isLogined = true;

        if (isSaveble)
        {
            SaveModelController.SaweUserData();
        }
        ServerController.onSuccessHandler -= SuccesLogin;

        CallMessage cmsg = new CallMessage();

        cmsg.from   = Models.user.user;
        cmsg.to     = SystemInfo.deviceUniqueIdentifier;
        cmsg.comand = "login";

        WEbSocketController.GetInstance.SendMessage(JsonUtility.ToJson(cmsg));
    }
        public static void Main(string[] args)
        {
            EasyClient client = new EasyClient();

            client.Initialize(new ProtobufReceiveFilter(), (info =>
            {
                switch (info.Type)
                {
                case DefeatMessage.Types.Type.BackMessage:
                    Console.WriteLine("BackMessage:{0}", info.Body.BackMessage.Content);
                    break;

                case DefeatMessage.Types.Type.CallMessage:
                    Console.WriteLine("CallMessage:{0}", info.Body.CallMessage.Content);
                    break;
                }
            }));
            var flag = client.ConnectAsync(new DnsEndPoint("127.0.0.1", 2012));

            if (flag.Result)
            {
                var callMessage = CallMessage.CreateBuilder()
                                  .SetContent("Hello I am form C# client by SuperSocket ClientEngine").Build();
                var message = DefeatMessage.CreateBuilder()
                              .SetType(DefeatMessage.Types.Type.CallMessage)
                              .SetCallMessage(callMessage).Build();

                using (var stream = new MemoryStream())
                {
                    CodedOutputStream os = CodedOutputStream.CreateInstance(stream);

                    os.WriteMessageNoTag(message);

                    os.Flush();

                    byte[] data = stream.ToArray();
                    client.Send(new ArraySegment <byte>(data));
                }
            }
            Console.ReadKey();
        }
Exemplo n.º 15
0
    public void onButtonClick()
    {
        HomePageControll.MODEL = this.model;

        if (HomePageControll.isCalling)
        {
            CallMessage cmsg = new CallMessage();
            cmsg.from   = Models.user.user;
            cmsg.to     = model.user;
            cmsg.comand = "call";

            Models.cmsg = cmsg;

            wayt.setCallMessage(cmsg);
            wayt.Activate();
        }
        else
        {
            SceneManager.LoadScene("SimpleCamera");
        }
    }
Exemplo n.º 16
0
    private void Start()
    {
        // 일반화
        Cal <int>    pluse_int    = new Cal <int>(Plus);
        Cal <float>  pluse_float  = new Cal <float>(Plus);
        Cal <double> pluse_double = new Cal <double>(Plus);

        Debug.Log(Calcuator(1, 2, pluse_int));
        Debug.Log(Calcuator(1.0f, 2.0f, pluse_float));

        //체인
        CallMessage dele = new CallMessage(Message_1);

        dele += Message_2;
        dele += Message_3;
        dele += Message_4;
        dele();
        dele -= Message_2;
        dele -= Message_3;
        dele += Message_4;
        dele();
    }
Exemplo n.º 17
0
        public void Send(string message, ConsoleColor color)
        {
            var flag = _socketClient.ConnectAsync(new DnsEndPoint("127.0.0.1", 2012));

            if (flag.Result)
            {
                var consoleColor = ConsoleColor.DarkRed.ToString();
                var callMessage  = CallMessage.CreateBuilder()
                                   .SetContent(string.Format("{0}%{1}", message, consoleColor)).Build();
                var msg = DefeatMessage.CreateBuilder()
                          .SetType(DefeatMessage.Types.Type.CallMessage)
                          .SetCallMessage(callMessage).Build();

                using (var stream = new MemoryStream())
                {
                    var os = CodedOutputStream.CreateInstance(stream);
                    os.WriteMessageNoTag(msg);
                    os.Flush();
                    var data = stream.ToArray();
                    _socketClient.Send(new ArraySegment <byte>(data));
                }
            }
        }
Exemplo n.º 18
0
        public void TestCallMessageRaisesOnCall(string message)
        {
            var          e           = new ManualResetEvent(false);
            var          wasCalled   = false;
            const string callId      = "ABC123";
            var          msg         = String.Format(message, callId);
            CallMessage  callMessage = null;

            _wampCommsHandler.Start(config =>
            {
                config.OnCall = m =>
                {
                    e.Set();
                    callMessage = m;
                    wasCalled   = true;
                };
            });

            _connMock.Object.OnMessage(msg);
            e.WaitOne(1000);
            Assert.True(wasCalled);
            Assert.IsNotNull(callMessage);
            Assert.AreEqual(callId, callMessage.CallId);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 请求结束
        /// </summary>
        /// <param name="reqMsg"></param>
        /// <param name="resMsg"></param>
        /// <param name="elapsedMilliseconds"></param>
        internal static void EndRequest(this IServiceLog logger, RequestMessage reqMsg, ResponseMessage resMsg, long elapsedMilliseconds)
        {
            if (logger == null)
            {
                return;
            }

            try
            {
                var callMsg = new CallMessage
                {
                    AppName     = reqMsg.AppName,
                    IPAddress   = reqMsg.IPAddress,
                    HostName    = reqMsg.HostName,
                    ServiceName = reqMsg.ServiceName,
                    MethodName  = reqMsg.MethodName,
                    Parameters  = reqMsg.Parameters
                };

                var returnMsg = new ReturnMessage
                {
                    ServiceName = resMsg.ServiceName,
                    MethodName  = resMsg.MethodName,
                    Parameters  = resMsg.Parameters,
                    Count       = resMsg.Count,
                    Error       = resMsg.Error,
                    Value       = resMsg.Value
                };

                //结束调用
                logger.End(callMsg, returnMsg, elapsedMilliseconds);
            }
            catch
            {
            }
        }
Exemplo n.º 20
0
 public void Init()
 {
     message = new CallMessage(callId, procUri, arg1, arg2);
 }
Exemplo n.º 21
0
 public CallResponseMessage Call(CallMessage request)
 {
     throw new NotImplementedException();
 }
 private SignalServiceCallMessage createCallMessage(CallMessage content)
 {
     if (content.OfferOneofCase == CallMessage.OfferOneofOneofCase.Offer)
     {
         return(new SignalServiceCallMessage()
         {
             OfferMessage = new OfferMessage()
             {
                 Id = content.Offer.Id,
                 Description = content.Offer.Description
             }
         });
     }
     else if (content.AnswerOneofCase == CallMessage.AnswerOneofOneofCase.Answer)
     {
         return(new SignalServiceCallMessage()
         {
             AnswerMessage = new AnswerMessage()
             {
                 Id = content.Answer.Id,
                 Description = content.Answer.Description
             }
         });
     }
     else if (content.IceUpdate.Count > 0)
     {
         var m = new SignalServiceCallMessage();
         var l = new List <IceUpdateMessage>();
         foreach (var u in content.IceUpdate)
         {
             l.Add(new IceUpdateMessage()
             {
                 Id            = u.Id,
                 SdpMid        = u.SdpMid,
                 SdpMLineIndex = u.SdpMLineIndex,
                 Sdp           = u.Sdp
             });
         }
         m.IceUpdateMessages = l;
         return(m);
     }
     else if (content.HangupOneofCase == CallMessage.HangupOneofOneofCase.Hangup)
     {
         return(new SignalServiceCallMessage()
         {
             HangupMessage = new HangupMessage()
             {
                 Id = content.Hangup.Id,
             }
         });
     }
     else if (content.BusyOneofCase == CallMessage.BusyOneofOneofCase.Busy)
     {
         return(new SignalServiceCallMessage()
         {
             BusyMessage = new BusyMessage()
             {
                 Id = content.Busy.Id
             }
         });
     }
     return(new SignalServiceCallMessage());
 }
Exemplo n.º 23
0
 public void End(CallMessage reqMsg, ReturnMessage resMsg, long elapsedTime)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 24
0
 public void Begin(CallMessage reqMsg)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 25
0
 public void setCallMessage(CallMessage _cmsg)
 {
     this.cmsg = _cmsg;
 }
 //TODO change string to TBaseData
 public abstract string SerializeCallMessage(CallMessage callMessage);
Exemplo n.º 27
0
    void OnNewMessage(Socket socket, Packet packet, params object[] args)
    {
        //addChatMessage();
        //data = args[0] as Dictionary<string, object>;
        var msg = args[0] as string;

        Debug.Log(msg);
        if (string.IsNullOrEmpty(msg))
        {
            return;
        }

        CallMessage cmsg = JsonUtility.FromJson <CallMessage>(msg);

        GlobalParameters.gcmsg      = new CallMessage();
        GlobalParameters.gcmsg.from = Models.user.user;
        GlobalParameters.gcmsg.to   = cmsg.from;
        if (cmsg.from.Equals(Models.user.user))
        {
            if (cmsg.comand.Equals("login"))
            {
                if (!SystemInfo.deviceUniqueIdentifier.Equals(cmsg.to))
                {
                    cmsg.comand = "outlog";
                    SendMessage(JsonUtility.ToJson(cmsg));
                }
            }
            if (cmsg.comand.Equals("outlog"))
            {
                if (SystemInfo.deviceUniqueIdentifier.Equals(cmsg.to))
                {
                    GlobalParameters.isLogined = false;
                    PlayerPrefs.DeleteKey("user");
                    GlobalParameters.IsUserLogined = true;
                    SceneManager.LoadScene(0);
                }
            }
        }

        if (cmsg.to.Equals(Models.user.user))
        {
            if (cmsg.comand.Equals("call"))
            {
                if (GlobalParameters.IsBusy)
                {
                    GlobalParameters.gcmsg.comand = "busy";
                    string data = JsonUtility.ToJson(GlobalParameters.gcmsg);
                    SendMessage(data);
                    return;
                }
                else
                {
                    CallPopupController.GetInstance.StartCall();
                    return;
                }
            }
            if (cmsg.comand.Equals("stop"))
            {
                if (GlobalParameters.IsBusy)
                {
                    return;
                }
                if (SceneManager.GetActiveScene().name.Equals("VideoChatGArage"))
                {
                    TestHome.GetInstance.onLeaveButtonClicked();
                    GlobalParameters.IsBusy = false;
                    SceneManager.LoadScene(0);
                }
                else
                {
                    CallPopupController.GetInstance.StopCall();
                }
                return;
            }
        }
    }
Exemplo n.º 28
0
 private static void OnCall(CallMessage callMessage)
 {
     Console.WriteLine("Event message received: {0}", callMessage.CallId);
 }