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()); }
public void ScoreScene() { SocketHelper sh = SocketHelper.GetInstance(); sh.SendMessage("LoadScore"); StartCoroutine(WaitLoadScore()); }
public void GameOver() { gameOverText.text = "Game Over!"; gameOver = true; SocketHelper s = SocketHelper.GetInstance(); s.SendMessage("GameOver;" + score.ToString() + ";"); }
public void send(int opCode, BasePacket packet) { JsonObject json = packet.toData(); json ["opcode"] = opCode; SocketHelper.GetInstance().SendMessage(json.ToString()); }
void Start() { //创建socket连接 SocketHelper s = SocketHelper.GetInstance(); //发送信息向服务器端 s.SendMessage("123"); }
// Update is called once per frame void Update() { if (isShow && SocketHelper.GetInstance().getHasMessage()) { showMessage(); SocketHelper.GetInstance().initHasMessage(); } }
// 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(); } }
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; }
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]; } }
public AddressSet() { InitializeComponent(); //初始化socket监听器, 开启线程进行socket监听 SocketHelper.GetInstance().Init(); //创建udp服务: 支持搜索控制卡、设置控制卡IP地址 UDPServices.GetInstance(); UDPServices.GetInstance().xmlRespond_ += this.XmlRespond; }
private string GetData() //在读取后才结束循环 { if (s == null) { s = SocketHelper.GetInstance(); } while (!s.isUpdate) { continue; } s.isUpdate = false; return(s.data.Trim()); }
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)); }
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)); } //记录操作 }
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(); } }
public void Send() { SocketHelper.GetInstance().SendMessage(this); }
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(); } }
//单例化测试 /*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(); }
public void Start() { //创建socket连接 s = SocketHelper.GetInstance(); //s = new SocketHelper(); }
void OnApplicationQuit() { SocketHelper.GetInstance().Closed(); }
//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(); }
public void closeSocket() { SocketHelper.GetInstance().Closed(); }
public void LoginSuccess() { NetTools.Log("LoginSuccess udi : " + LoginManager.Uid); SocketHelper.GetInstance().Connect(ConnectCallBack, null); }
//窗口关闭事件函数 private void AddressSet_FormClosed(object sender, FormClosedEventArgs e) { //窗体退出时等待后台线程退出后再关闭窗口 SocketHelper.GetInstance().Exit(); }