public void run() //執行Socket { IPEndPoint ipep = new IPEndPoint(IPAddress.Any, ChatSetting.port); Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); newsock.Bind(ipep); newsock.Listen(10); while (true) { Socket socket = newsock.Accept(); Console.WriteLine("接受一個新連線!"); ChatSocket client = new ChatSocket(socket); try { client.number = _clientList.Count(); _clientList.Add(client); client.newListener(processMsgComeIn); } catch { } // clientList.Remove(client); } // newsock.Close(); }
public float StopRecord() { if (micArray.Length == 0) { return(0); } if (!Microphone.IsRecording(null)) { return(0); } int lastTime = Microphone.GetPosition(null); Microphone.End(null); if (lastTime <= 0) { return(0); } float[] samples = new float[redioclip.samples]; // redioclip.GetData(samples, 0); float[] clipSamples = new float[lastTime]; Array.Copy(samples, clipSamples, clipSamples.Length - 1); redioclip = AudioClip.Create("playRecordClip", clipSamples.Length, 1, 8000, false); redioclip.SetData(clipSamples, 0); SoundCtrl.playAudio.clip = redioclip; ChatSocket.getInstance().sendMsg(new MicInputRequest(userList, GetClipData())); PlayRecord(); return(redioclip.length); }
private void RoomBackResponse(ClientResponse response) { watingPanel.SetActive(false); if (GlobalDataScript.homePanel != null) { GlobalDataScript.homePanel.GetComponent <HomePanelScript>().removeListener(); Destroy(GlobalDataScript.homePanel); } if (GlobalDataScript.gamePlayPanel != null) { GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript>().exitOrDissoliveRoom(); } GlobalDataScript.reEnterRoomData = JsonMapper.ToObject <RoomJoinResponseVo>(response.message); for (int i = 0; i < GlobalDataScript.reEnterRoomData.playerList.Count; i++) { AvatarVO itemData = GlobalDataScript.reEnterRoomData.playerList[i]; if (itemData.account.openid == GlobalDataScript.loginResponseData.account.openid) { GlobalDataScript.loginResponseData.account.uuid = itemData.account.uuid; ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid)); break; } } GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePlay"); removeListener(); Destroy(this); Destroy(gameObject); }
public void login() { MyDebug.Log("----------------1-------------------"); if (!CustomSocket.getInstance().isConnected) { CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); tapCount = 0; MyDebug.Log("----------------2------------------"); return; } GlobalDataScript.reinitData(); //初始化界面数据 if (agreeProtocol.isOn) { MyDebug.Log("----------------3------------------"); doLogin(); watingPanel.GetComponentInChildren <Text>().text = "进入游戏中"; watingPanel.SetActive(true); } else { MyDebug.Log("请先同意用户使用协议"); TipsManagerScript.getInstance().setTips("请先同意用户使用协议"); } tapCount += 1; Invoke("resetClickNum", 10f); }
/// <summary> /// 异步连接的回调函数 /// </summary> /// <param name="ar"></param> private void ConnectCallback(IAsyncResult ar) { //connectDone.Set(); if ((tcpclient != null) && (tcpclient.Connected)) { stream = tcpclient.GetStream(); asyncread(tcpclient); MyDebug.Log("--chatSocketUrl-------ConnectCallback-----聊天服务器已经连接---"); MyDebug.Log("聊天服务器已经连接!"); // showMessageTip ("聊天服务器已经连接!"); } else { MyDebug.Log("--chatSocketUrl-------ConnectCallback----已经断开连接---"); closeSocket(); return; } TcpClient t = (TcpClient)ar.AsyncState; try { t.EndConnect(ar); } catch (Exception ex) { //设置标志,连接服务端失败! Debug.Log(ex.ToString()); } if (!init) { init = true; ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid)); } }
public void CloseSocket(ChatSocket sc) { try { if (clients.Count == 0) { return; } for (int i = 0; i < clients.Count; i++) { SocketStatus s = clients[i]; if (s.scocKet.Connected) { if (s.Ip == sc.RemoteEndPoint.Address.ToString() && s.Port == sc.RemoteEndPoint.Port.ToString()) { clients.Remove(s); } } } } catch (Exception ex) { Log.WriteLog("wms连接不稳定"); } // FormMain.globalFrm.gdvWmsConn.RefreshData(); // sc.Close(); }
public void login() { SoundCtrl.getInstance().playSoundUI(true); if (!CustomSocket.getInstance().isConnected) { CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); tapCount = 0; return; } GlobalDataScript.reinitData();//初始化界面数据 if (agreeProtocol.isOn) { doLogin(); watingPanel.SetActive(true); } else { MyDebug.Log("请先同意用户使用协议"); TipsManagerScript.getInstance().setTips("请先同意用户使用协议"); } tapCount += 1; Invoke("resetClickNum", 10f); }
public void LoginCallBack(ClientResponse response) { if (watingPanel != null) { watingPanel.SetActive(false); } SoundCtrl.getInstance().stopBGM(); SoundCtrl.getInstance().playBGM(); if (response.status == 1) { if (GlobalDataScript.homePanel != null) { GlobalDataScript.homePanel.GetComponent <HomePanelScript>().removeListener(); Destroy(GlobalDataScript.homePanel); } GlobalDataScript.loginResponseData = JsonMapper.ToObject <AvatarVO>(response.message); ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid)); panelCreateDialog = Instantiate(Resources.Load("Prefab/Panel_Home")) as GameObject; panelCreateDialog.transform.parent = GlobalDataScript.getInstance().canvsTransfrom; panelCreateDialog.transform.localScale = Vector3.one; panelCreateDialog.GetComponent <RectTransform>().offsetMax = new Vector2(0f, 0f); panelCreateDialog.GetComponent <RectTransform>().offsetMin = new Vector2(0f, 0f); GlobalDataScript.homePanel = panelCreateDialog; removeListener(); Destroy(this); Destroy(gameObject); } }
public void init() { _socket = new CustomSocket(onSocketData, onSocketStatus); _chatSocket = new ChatSocket(onSocketData, null); _cache = new List <ClientResponse> (); heartbeatThread(); //开一个线程维持与服务的心跳 }
public void LoginCallBack(ClientResponse response) { if (response.status == 1) { if (GlobalDataScript.homePanel != null) { GlobalDataScript.homePanel.GetComponent <HomePanelScript> ().removeListener(); Destroy(GlobalDataScript.homePanel); } if (GlobalDataScript.gamePlayPanel != null) { if (GlobalDataScript.roomVo.gameType == (int)GameTypePK.NULL) { GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.roomVo.gameType == (int)GameTypePK.PDK) { GlobalDataScript.gamePlayPanel.GetComponent <MyPDKScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.roomVo.gameType == (int)GameTypePK.DN) { GlobalDataScript.gamePlayPanel.GetComponent <MyDNScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.roomVo.gameType == (int)GameTypePK.DZPK) { GlobalDataScript.gamePlayPanel.GetComponent <MyDZPKScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.roomVo.gameType == (int)GameTypePK.AMH) { GlobalDataScript.gamePlayPanel.GetComponent <MyDZPKScript>().exitOrDissoliveRoom(); } } GlobalDataScript.loginResponseData = JsonMapper.ToObject <AvatarVO> (response.message); ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid)); GlobalDataScript.loadTime = GlobalDataScript.GetTimeStamp(); panelCreateDialog = Instantiate(Resources.Load("Prefab/Panel_Home")) as GameObject; panelCreateDialog.transform.parent = GlobalDataScript.getInstance().canvsTransfrom; panelCreateDialog.transform.localScale = Vector3.one; panelCreateDialog.GetComponent <RectTransform> ().offsetMax = new Vector2(0f, 0f); panelCreateDialog.GetComponent <RectTransform> ().offsetMin = new Vector2(0f, 0f); GlobalDataScript.homePanel = panelCreateDialog; GlobalDataScript.homePanel.GetComponent <HomePanelScript> ().initUI(); removeListener(); Destroy(this); Destroy(gameObject); } if (watingPanel != null) { //watingPanel.SetActive(false); } }
public static ChatSocket getInstance() { if (_instance == null) { _instance = new ChatSocket(); //_instance.Connect (); } return(_instance); }
private static void sendHeartbeat() { if (CustomSocket.getInstance().isConnected) { CustomSocket.getInstance().sendHeadData(); ChatSocket.getInstance().sendHeadData(); } Thread.Sleep(20000); sendHeartbeat(); }
/// <summary> /// 3) 接收消息 ---路由电报 /// </summary> /// <param name="clientSocket"></param> public void ReceiveMessage(byte[] clientSocket, ChatSocket soket) { try { } catch (Exception ex) { Log.WriteLog("异常3" + ex.Message + ex.TargetSite); } }
public void setChatroomIndex(ChatSocket socket, int index) { foreach (Member m in memberList) { if (m.socket.Equals(socket)) { m.chatroomIndex = index; } break; } }
public GameObject watingPanel; //正在登陆,请稍候 void Start() { CustomSocket.getInstance().hasStartTimer = false; CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); GlobalDataScript.isonLoginPage = true; SocketEventHandle.getInstance().TestMesgCallBack += TestMesgCallBack; SocketEventHandle.getInstance().LoginCallBack += LoginCallBack; SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse; versionText.text = "版本号:" + Application.version; }
void Start() { CustomSocket.getInstance().hasStartTimer = false; CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); GlobalDataScript.isonLoginPage = true; SocketEventHandle.getInstance().LoginCallBack += LoginCallBack; SocketEventHandle.getInstance().LoginWeChatCallBack += LoginWeChatCallBack; SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse; PlatformBridge.Instance.WeChatLoginListener += WeChatLoginCallBack; versionText.text = "版本号:" + Application.version; }
void Start() { //shareSdk.showUserHandler = getUserInforCallback;//注册获取用户信息回调 CustomSocket.hasStartTimer = false; CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); GlobalDataScript.isonLoginPage = true; SocketEventHandle.getInstance().LoginCallBack += LoginCallBack; SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse; versionText.text = "版本号:" + Application.version; //WxPayImpl test = new WxPayImpl(gameObject); //test.callTest ("dddddddddddddddddddddddddddd"); }
public ChatView(ChatSocket chatSocket) { _chatSocket = chatSocket; _chatUnit = new ChatUIUnit(); _chator = new Chator() { ChatorId = Guid.NewGuid().ToString(), ChatorName = Utils.GenRandomName() }; _receivedMessageBox = new Subject <ChatMessageModel>(); _sendMessageBox = new Subject <ChatMessageModel>(); // 消息监听 Subscribe(); _chatSocket.Connect(); // 开启socket接收消息 _chatSocket.ListenReceiveMessageOnTask(OnReceiveMessage); GoChatRoom(); }
public void StopRecord() { MyDebug.Log("StopRecord"); if (micArray.Length == 0) { Debug.Log("No Record Device!"); return; } if (!Microphone.IsRecording(null)) { return; } Microphone.End(null); GetComponent <AudioSource>().Stop(); ChatSocket.getInstance().sendMsg(new MicInputRequest(userList, GetClipData())); PlayRecord(); }
IEnumerator Start() { _cs = GetComponent <ChatSocket> (); _thresh_step = (_max_done_thresh - _min_done_thresh) / (float)_max_thresh_len; LogSystem.InstallDefaultReactors(); TextAsset jsonCredText = Resources.Load("stt_creds") as TextAsset; CredText creds = JsonUtility.FromJson <CredText>(jsonCredText.text); // Create credential and instantiate service _credentials = new Credentials(creds.username, creds.password, creds.url); _speechToText = new SpeechToTextService(_credentials); yield return(new WaitForSeconds(1)); this.Active = true; StartRecording(); Log.Debug("SpeechListener.Start()", "SpeechToText.isListening: {0}", _speechToText.IsListening); }
public LogInWindow(string serverIp) { InitializeComponent(); gridHome.Visibility = Visibility.Collapsed; stackPanelLogIn.Visibility = Visibility.Visible; this.req_packet = new Packet(); this.client = ChatSocket.connect(serverIp); try { client.newListener(receiveFromServer); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
IEnumerator ConnectTime1(float time, byte type) { connectRetruen = false; yield return(new WaitForSeconds(time)); if (!connectRetruen) {//超过5秒还没连接成功显示失败 if (type == 1) { CustomSocket.hasStartTimer = false; CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); GlobalDataScript.isonLoginPage = true; } else if (type == 2) { } } }
public void loginWechat() { SoundCtrl.getInstance().playSoundUI(true); if (!CustomSocket.getInstance().isConnected) { CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); tapCount = 0; return; } GlobalDataScript.reinitData(); //初始化界面数据 if (agreeProtocol.isOn) { // doLogin(); if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor) { WeChatLoginCallBack("{\"access_token\":" + "\"BYl9EIcjwyVFdP3F8ZIo8_OrDlMi4MNKFRDGdl_3KkmtU5YLl7Vgi4dw17I24tS2af2CqhBX6X3p9R5emnZOen8SvuFkNn5_wd4042L3d2w\"," + "\"expires_in\":7200," + "\"refresh_token\":" + "\"BQhqiKHK_cUnED8a1CfRgUcXuS4EyGcq9XQAdj-N-3ctMUoG6VxzTROBIe7m1Q2Ws17br6MJxk85tIbMz4ecsI1VEXsfslh9jyWN1Xjt6vc\"," + "\"openid\":\"o3LILj-8xTgvce2P_QBjMrgDZdQg\"," + "\"scope\":\"snsapi_userinfo\"," + "\"unionid\":\"oHRAHuO86ExIL6tLdyAkFSFlEoYw\"}"); } else { PlatformBridge.Instance.doWeChatLogin(); watingPanel.SetActive(true); } } else { MyDebug.Log("请先同意用户使用协议"); TipsManagerScript.getInstance().setTips("请先同意用户使用协议"); } tapCount += 1; Invoke("resetClickNum", 10f); }
void Start() { (this.transform as RectTransform).sizeDelta = new Vector2(1136, 640); DOTween.Init(false, true, LogBehaviour.Default); if (null != PanelSafeGame) { PanelSafeGame.GetComponent <CanvasGroup>().DOFade(0, 1.0f).SetDelay(1.0f).OnComplete(FadeOutSafeGame); } //shareSdk.showUserHandler = getUserInforCallback;//注册获取用户信息回调 CustomSocket.hasStartTimer = false; CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); GlobalDataScript.isonLoginPage = true; SocketEventHandle.getInstance().LoginCallBack += LoginCallBack; SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse; versionText.text = "版本号:" + Application.version; //WxPayImpl test = new WxPayImpl(gameObject); //test.callTest ("dddddddddddddddddddddddddddd"); }
void Start() { CustomSocket.getInstance().hasStartTimer = false; CustomSocket.getInstance().Connect(); ChatSocket.getInstance().Connect(); GlobalDataScript.isonLoginPage = true; SocketEventHandle.getInstance().UpdateGlobalData += UpdateGlobalData; SocketEventHandle.getInstance().LoginCallBack += LoginCallBack; SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse; versionText.text = "版本号:" + Application.version; #if UNITY_IPHONE canGuestLogin = GlobalDataScript.inAppPay; canWechatLogin = GlobalDataScript.getInstance().wechatOperate.isWechatValid(); agreement.SetActive(!canGuestLogin); guestLogin.SetActive(canGuestLogin); if (canGuestLogin) { wechatLogin.SetActive(canWechatLogin); } #endif }
private bool logIn(string username) { myName = username; if (this.client == null) { this.client = ChatSocket.connect(ChatSetting.serverIp); try { client.newListener(receiveFromServer); } catch (Exception e) { Console.WriteLine(e.ToString()); } } bool connectSuccess; //client = ChatSocket.connect(ChatSetting.serverIp); if (client == null) { connectSuccess = false; } else { connectSuccess = true; } if (connectSuccess) { LoginIn = true; Packet packet = new Packet(); packet.makePacketReportName(username, this.textBoxPassword.Password); sendToServer(null, packet); } return(connectSuccess); }
private void RoomBackResponse(ClientResponse response) { if (GlobalDataScript.gamePlayPanel != null) { GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript>().exitOrDissoliveRoom(); } GlobalDataScript.reEnterRoomData = JsonMapper.ToObject <RoomJoinResponseVo>(response.message); for (int i = 0; i < GlobalDataScript.reEnterRoomData.playerList.Count; i++) { AvatarVO itemData = GlobalDataScript.reEnterRoomData.playerList[i]; if (itemData.account.openid == GlobalDataScript.loginResponseData.account.openid) { GlobalDataScript.loginResponseData.account.uuid = itemData.account.uuid; GlobalDataScript.loginResponseData.isOnLine = true; ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid)); break; } } GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePlay"); }
private void RoomBackResponse(ClientResponse response) { if (GlobalDataScript.homePanel != null) { GlobalDataScript.homePanel.GetComponent <HomePanelScript> ().removeListener(); Destroy(GlobalDataScript.homePanel); } GlobalDataScript.reEnterRoomData = JsonMapper.ToObject <RoomCreateVo> (response.message); GlobalDataScript.goldType = GlobalDataScript.reEnterRoomData.goldType; if (GlobalDataScript.gamePlayPanel != null) { if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.NULL) { GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.PDK) { GlobalDataScript.gamePlayPanel.GetComponent <MyPDKScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DN) { GlobalDataScript.gamePlayPanel.GetComponent <MyDNScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DZPK) { GlobalDataScript.gamePlayPanel.GetComponent <MyDZPKScript> ().exitOrDissoliveRoom(); } else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.AMH) { GlobalDataScript.gamePlayPanel.GetComponent <MyDZPKScript>().exitOrDissoliveRoom(); } } for (int i = 0; i < GlobalDataScript.reEnterRoomData.playerList.Count; i++) { AvatarVO itemData = GlobalDataScript.reEnterRoomData.playerList [i]; if (itemData.account.openid == GlobalDataScript.loginResponseData.account.openid) { GlobalDataScript.loginResponseData.account.uuid = itemData.account.uuid; GlobalDataScript.loginResponseData.account.roomcard = itemData.account.roomcard; GlobalDataScript.loginResponseData.account.gold = itemData.account.gold; GlobalDataScript.loginResponseData.account.isCheat = itemData.account.isCheat; ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid)); break; } } if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.NULL) { GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePlay"); } else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.PDK) { GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePDK"); } else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DN) { GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GameDN"); } else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DZPK) { GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GameDZPK"); } else if (GlobalDataScript.roomVo.gameType == (int)GameTypePK.AMH) { GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GameAMH"); } removeListener(); Destroy(this); Destroy(gameObject); }
// public string SeqId = string.Empty; private void HandleMessageReceived(ClientManager cm, TimedEventArgs ea) //处理接收信息 { ChatSocket chatSocket = cm.ChatSocket; if (chatSocket.Command == ChatCommand.PublicMessage) { // SendResponsePacketTo(aClient, chatSocket.Command, pck); if (chatSocket.Command == ChatCommand.PrivateMessage) } else { string returnStr = ""; ChatSocket chatSockets = cm.ChatSocket; byte[] recby = chatSocket.ReceiveByte; string pck = chatSockets.Metatype; //数据判断及解析 if (recby != null) { if (recby.Length < 3) { return; } for (int i = 0; i < recby.Length; i++) { returnStr += recby[i].ToString("X2"); //ToString("X2") 为C#中的字符串格式控制符 } } if (returnStr.Trim().Length < 5) { return; } // 开始逻辑判断 returnStr = returnStr.Substring(2); if (returnStr.Trim().Length == 0) { return; } if (returnStr.Length < 12) { return; } string seqWms = returnStr.Substring(4, 8); string flag = returnStr.Substring(12, 2); if (flag == "84") { Log.WriteLog(DateTime.Now + "接受顺丰落袋反馈消息:" + returnStr); return; } if (flag == "85") { Log.WriteLog(DateTime.Now + "接受顺丰打印反馈消息:" + returnStr); return; } if (flag == "86") { Log.WriteLog(DateTime.Now + "接受顺丰满袋反馈消息:" + returnStr); return; } if (flag == "83") { lock (lckdata) { try { string postStr = "AA" + returnStr; Post post = new Post(postStr); Data83Rec data83Rec = new Data83Rec(post.Data); string codeProt = data83Rec.Code; string sendIdt = "" + data83Rec.Seq; // noread的情况下,code长度为0 if (0 == data83Rec.CodeLen) { codeProt = map[sendIdt].ToString(); } map.Remove(sendIdt); setCode("", ""); object[] values = new object[3]; values[0] = GetPlcId(); Log.WriteLog("接受顺丰格口返回消息:" + returnStr); string port1 = data83Rec.Port; Log.WriteLog(port1 + " wms return "); int truePort = 0; //if (port1.Contains("F") || port1.Contains("E") || port1.Contains("D")) //{ // values[1] = 13; //} //else //{ truePort = Convert.ToInt32(port1, 16); values[1] = truePort; //} values[2] = sendIdt; PlcFactory.Instance().WritePlcDataDB("ToPlc_seq%", new[] { values[2] }); PlcFactory.Instance().WritePlcDataDB("ToPlc_barcode%", new object[] { codeProt }); //格口状态检测,异常则去19 string errText = String.Empty; //string SL_State = PlcFactory.Instance().ReadPlcDbValue("满袋" + values[1].ToString() + "%", ref errText); //if (SL_State.Equals("-1")) //{ // values[1] = 19; //} PlcFactory.Instance().WritePlcDataDB("ToPlc_bag%", new object[] { values[1] }); Log.WriteLog(values[0].ToString() + "写入PLC成功" + port1 + " plc" + sendIdt + "WMS反馈落袋格口:"); if (codeProt.Trim() != "") { //原先是从记录表开始存储 然后现在添加到正式表并更改记录表里条码状态字段 //datalog.AddDjmx(codeProt, values[0].ToString(), values[1].ToString()); //现在的思路 在开始存储的时候就存在正式表里 然后在这里更改条码的一些字段 createdata.UpdateDjmx(codeProt, values[0].ToString(), values[1].ToString()); } //孙 添加数量 //int sum = 0; //DataTable tb = createdata.SelectSum(values[1].ToString()); //if (tb.Rows.Count > 0) //{ // int test = Convert.ToInt32(tb.Rows[0]["sts"]); // if (DBNull.Value != tb.Rows[0]["count"]) // { // int i = Convert.ToInt32(tb.Rows[0]["count"]); // sum = i + 1; // } // else // { // sum = 1; // } // createdata.UpdateProtStsSum(values[1].ToString(), sum); //} } catch (Exception ex) { Log.WriteLog(DateTime.Now + "接受顺丰格口返回消息异常 :" + returnStr); setCode("", ""); } } return; } if (flag == "88") { string port = returnStr.Substring(26, 4); //格口 string error = returnStr.Substring(30, 1); //格口 string ss = returnStr.Substring(30, 1); System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding(); byte[] byteArray = new byte[] { byte.Parse(ss) }; string strCharacter = asciiEncoding.GetString(byteArray); //datalog.UpdateErrProtSts(port, strCharacter, "2"); createdata.UpdateErrProtSts(port, strCharacter, "2"); List <byte> wmsSeq = new List <byte>(); wmsSeq.Add(Convert.ToByte(seqWms.Substring(0, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(2, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(4, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(6, 2), 16)); string seqId = string.Empty; ErrWmsSendData(0x88, 0x0A, wmsSeq, ref seqId); return; } if (flag == "89") { string seqId = string.Empty; string port = returnStr.Substring(26, 4); //格口 //datalog.UpdateErrProtSts(port, "", "0"); createdata.UpdateErrProtSts(port, "", "0"); List <byte> wmsSeq = new List <byte>(); wmsSeq.Add(Convert.ToByte(seqWms.Substring(0, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(2, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(4, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(6, 2), 16)); ErrWmsSendData(0x89, 0x0A, wmsSeq, ref seqId); return; } #region 心跳回复 if (flag == "80") //心跳回复 { new Thread((ThreadStart) delegate { try { List <byte> wmsSeq = new List <byte>(); wmsSeq.Add(0x00); wmsSeq.Add(Convert.ToByte(seqWms.Substring(0, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(2, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(4, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(6, 2), 16)); string data = string.Empty; byte[] array = System.Text.Encoding.ASCII.GetBytes("LS01"); for (int j = 0; j < array.Length; j++) { wmsSeq.Add(array[j]); } string seqId = string.Empty; ErrWmsSendData(0x80, 0x0E, wmsSeq, ref seqId); } catch (Exception ex) { Log.WriteLog(seqWms); } }).Start(); return; ; } #endregion #region 自检消息回复 if (flag == "81") //自检消息回复 { new Thread((ThreadStart) delegate { string errtext = string.Empty; List <byte> wmsSeq = new List <byte>(); wmsSeq.Add(0x00); wmsSeq.Add(Convert.ToByte(seqWms.Substring(0, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(2, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(4, 2), 16)); wmsSeq.Add(Convert.ToByte(seqWms.Substring(6, 2), 16)); string seqId = string.Empty; ErrWmsSendData(0x81, 0x0A, wmsSeq, ref seqId); #region 检测设备 string sts = PlcFactory.Instance().ReadPlcDbValue("读取序号%", ref errtext).ToString(); List <byte> wcsData = new List <byte>(); wmsSeq.Clear(); if (sts != "01") //Plc故障 { // List<byte> wmsSeq = new List<byte>(); wmsSeq.Add(0x00); ErrWmsSendData(0x82, 0x06, wmsSeq, ref seqId); } else { wmsSeq.Add(0x01); ErrWmsSendData(0x82, 0x06, wmsSeq, ref seqId); } }).Start(); #endregion } #endregion } }
public Member(ChatSocket socket, int chatroomIndex) { this.socket = socket; this.chatroomIndex = chatroomIndex; }