コード例 #1
0
    public void send(int opCode, JsonObject packetData)
    {
        SimpleJson.JsonObject json = (SimpleJson.JsonObject)SimpleJson.SimpleJson.DeserializeObject(packetData.ToString());
        json ["opcode"] = opCode;

        SocketHelper.GetInstance().SendMessage(json.ToString());
    }
コード例 #2
0
    public void ScoreScene()
    {
        SocketHelper sh = SocketHelper.GetInstance();

        sh.SendMessage("LoadScore");
        StartCoroutine(WaitLoadScore());
    }
コード例 #3
0
    public void GameOver()
    {
        gameOverText.text = "Game Over!";
        gameOver          = true;
        SocketHelper s = SocketHelper.GetInstance();

        s.SendMessage("GameOver;" + score.ToString() + ";");
    }
コード例 #4
0
    public void send(int opCode, BasePacket packet)
    {
        JsonObject json = packet.toData();

        json ["opcode"] = opCode;

        SocketHelper.GetInstance().SendMessage(json.ToString());
    }
コード例 #5
0
    void Start()
    {
        //创建socket连接
        SocketHelper s = SocketHelper.GetInstance();

        //发送信息向服务器端
        s.SendMessage("123");
    }
コード例 #6
0
 // Update is called once per frame
 void Update()
 {
     if (isShow && SocketHelper.GetInstance().getHasMessage())
     {
         showMessage();
         SocketHelper.GetInstance().initHasMessage();
     }
 }
コード例 #7
0
ファイル: MessageList.cs プロジェクト: zpc97/Unity-Project
 // Update is called once per frame
 void Update()
 {
     if (SocketHelper.GetInstance().getHasSetMessage())
     {
         IDS.Add(SocketHelper.GetInstance().getID());
         messages.Add(SocketHelper.GetInstance().getMessage());
         SocketHelper.GetInstance().initHasSetMessage();
     }
 }
コード例 #8
0
 public AddressSet()
 {
     InitializeComponent();
     //Initialize the socket listener, start the thread for socket monitoring
     SocketHelper.GetInstance().Init();
     //Create udp service: support search control card, set control card IP address
     UDPServices.GetInstance();
     UDPServices.GetInstance().xmlRespond_ += this.XmlRespond;
 }
コード例 #9
0
ファイル: ScoreRanking.cs プロジェクト: zpc97/Unity-Project
    public void setScore()
    {
        SocketHelper sh = SocketHelper.GetInstance();

        sh.getScoreList();
        Debug.Log(PlayerPrefs.GetString("score", "empty"));
        string[] scores = PlayerPrefs.GetString("score", "empty").Split(';');
        for (int i = 0; i < scores.Length - 1; i++)
        {
            scoreTexts[i].text = scores[i];
        }
    }
コード例 #10
0
ファイル: AddressSet.cs プロジェクト: toobright/sdk
        public AddressSet()
        {
            InitializeComponent();

            //初始化socket监听器, 开启线程进行socket监听
            SocketHelper.GetInstance().Init();

            //创建udp服务: 支持搜索控制卡、设置控制卡IP地址
            UDPServices.GetInstance();

            UDPServices.GetInstance().xmlRespond_ += this.XmlRespond;
        }
コード例 #11
0
 private string GetData() //在读取后才结束循环
 {
     if (s == null)
     {
         s = SocketHelper.GetInstance();
     }
     while (!s.isUpdate)
     {
         continue;
     }
     s.isUpdate = false;
     return(s.data.Trim());
 }
コード例 #12
0
        public ActionResult AjaxThresholdModi(decimal setvalue, int id)
        {
            SocketHelper.GetInstance();
            SocketHelper.InitSocket();
            SocketHelper.SendMessage(setvalue.ToString());
            Thread.Sleep(2000);
            if (SocketHelper.Flag == true)
            {
            }
            else
            {
            }

            var res = thresholdSer.QueryWhere(t => t.ID == id).FirstOrDefault();

            if (setvalue == res.CurrentValue)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
            res.CurrentValue = setvalue;
            res.SetValue     = setvalue;
            thresholdSer.Update(res);
            if (thresholdSer.SaveChanges() > 0)
            {
                //     #region 直接传入数据到opc,现在是测试,能使用,但是需要进一步加入到场景之中才有具体意义
                //opcItemList = opcHelperItemServices.QueryWhere();
                //opc.OPCList.AddRange(opcItemList);
                ////获取DBContext
                //string serverName = "Kepware.KEPServerEX.V6";
                //string serverNode = "192.168.14.113";
                //opc.Connect(serverName, serverNode);
                //#endregion
                //     opc.AsyncWriteOpcItems(TagList.SimTest_F005_A001_Inlet_SQ.ToString(), setvalue);
                //    opc.SyncReadOpcItems();
                //    var getValue= opc.OPCList[(int)TagList.SimTest_F005_A001_Inlet_SQ].Value;
                //    if(setvalue==Convert.ToDecimal(getValue))
                //        return Json(setvalue,JsonRequestBehavior.AllowGet);
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
コード例 #13
0
        public ActionResult CentriStateSender(string tag, string tagvalue)
        {
            //SocketHelper.GetInstance();
            //SocketHelper.InitSocket();
            //SocketHelper.SendMessage(tagvalue.ToString());
            Thread.Sleep(2000);
            string ip      = Session[Keys.userIP].ToString();
            int    a       = 5;
            string message = "{'IP':'192.168.14.132','SimTest_F001_PressDesign_S001_E001_Press':'23','SimTest_F001_PressDesign_S001_E002_Press2':'214'}";
            string mess    = "{'IP':'" + ip + "','" + tag + "':'" + tagvalue + "'}";

            SocketHelper.GetInstance();
            SocketHelper.InitSocket();
            SocketHelper.SendMessage(mess.ToString());
            if (a > 4)
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("NO", JsonRequestBehavior.AllowGet));
            }
            //记录操作
        }
コード例 #14
0
    void OnGUI()
    {
        high = 10;
        if (CreateBtn("connect"))
        {
            SocketHelper.GetInstance().Connect("192.168.1.91", 9999, ConnectCallBack, null);
        }
        if (CreateBtn("Entry Game"))
        {
            EntryGameReq req = new EntryGameReq(123);
            req.Send();
        }

        if (CreateBtn("sendA"))
        {
            TestAReq req = new TestAReq(1, 9999999999999, "123abcd的");
            req.Send();
        }
        if (CreateBtn("sendB"))
        {
            TestBReq req = new TestBReq();
            req.Send();
        }
    }
コード例 #15
0
ファイル: Request.cs プロジェクト: zxy585/UnityNetWork
 public void Send()
 {
     SocketHelper.GetInstance().SendMessage(this);
 }
コード例 #16
0
ファイル: test.cs プロジェクト: LiuFeng1011/Diablo
    void OnGUI()
    {
        high = 10;
        if (CreateBtn("connect"))
        {
            SocketHelper.GetInstance().Connect(ConnectCallBack, null);
        }

        if (CreateBtn("send"))
        {
        }

        if (CreateBtn("login"))
        {
            LoginManager.Instance().httpFinishedDelegate = LoginSuccess;
            LoginManager.Instance().Login("liufeng1", "123456");
        }

        if (CreateBtn("reg"))
        {
            LoginManager.Instance().httpFinishedDelegate = LoginSuccess;
            LoginManager.Instance().Regist("liufeng1", "123456");
        }
        if (CreateBtn("shopping"))
        {
            PlayerRequest req = new PlayerRequest();
            req.Shopping(1001);
            req.Send();
        }
        if (CreateBtn("CHANGENAME"))
        {
            PlayerRequest req = new PlayerRequest();
            req.ChangeName("打算");
            req.Send();
        }
        if (CreateBtn("Set name color"))
        {
            PlayerRequest req = new PlayerRequest();
            req.SetNameColor(4001002);
            req.Send();
        }
        if (CreateBtn("Set role"))
        {
            PlayerRequest req = new PlayerRequest();
            req.SetRoleId(2001034);
            req.Send();
        }

        if (CreateBtn("Buy item"))
        {
            PlayerRequest req = new PlayerRequest();
            req.BuyItem(2002001);
            req.Send();
        }
        if (CreateBtn("Use item"))
        {
            PlayerRequest req = new PlayerRequest();
            req.UseItem(4001002, 1);
            req.Send();
        }

//		if(CreateBtn(  "CreateRoom"))
//		{
//			RoomRequest req = new RoomRequest();
//			req.CreateRoom(0);
//			req.Send();
//		}

        if (CreateBtn("InRoom"))
        {
            RoomRequest req = new RoomRequest();
            req.InRoom("5555");
            req.Send();
        }
        if (CreateBtn("Move"))
        {
            PlayerActionRequest req = new PlayerActionRequest();
            req.Move(new Vector3(1231, 324, 123), new Vector3(1, 1, 1));
            req.Send();
        }

        if (CreateBtn("TEST"))
        {
            TestRequest req = new TestRequest();
            req.Send();
        }
    }
コード例 #17
0
    //单例化测试

    /*public static SocketConnector instance;
     * public static SocketConnector Instance
     * {
     *  get
     *  {
     *      if(instance == null)
     *          instance = GameObject.Find("ScendData").GetComponent<SocketConnector>();
     *      return instance;
     *  }
     * }*/

    private SocketConnector()
    {
        s = SocketHelper.GetInstance();
    }
コード例 #18
0
 public void Start()
 {
     //创建socket连接
     s = SocketHelper.GetInstance();
     //s = new SocketHelper();
 }
コード例 #19
0
 void OnApplicationQuit()
 {
     SocketHelper.GetInstance().Closed();
 }
コード例 #20
0
 //Window close event function
 private void AddressSet_FormClosed(object sender, FormClosedEventArgs e)
 {
     //When the form exits, wait for the background thread to exit before closing the window
     SocketHelper.GetInstance().Exit();
 }
コード例 #21
0
 public void closeSocket()
 {
     SocketHelper.GetInstance().Closed();
 }
コード例 #22
0
ファイル: test.cs プロジェクト: LiuFeng1011/Diablo
    public void LoginSuccess()
    {
        NetTools.Log("LoginSuccess udi : " + LoginManager.Uid);

        SocketHelper.GetInstance().Connect(ConnectCallBack, null);
    }
コード例 #23
0
ファイル: AddressSet.cs プロジェクト: toobright/sdk
 //窗口关闭事件函数
 private void AddressSet_FormClosed(object sender, FormClosedEventArgs e)
 {
     //窗体退出时等待后台线程退出后再关闭窗口
     SocketHelper.GetInstance().Exit();
 }