public void SetMessageName(CDecompress msgDataDecompresser, string needDecompressMsgName) { if (msgProtolType == 3) { messageName = System.Text.Encoding.UTF8.GetString(buffer, 4, this.PeekUInt16(2, true)); } else { this.msgDataDecompresser = msgDataDecompresser; this.needDecompressMsgName = needDecompressMsgName; //命令分组 messageName = BitConverter.ToInt32(buffer, 0).ToString(); } }
static int QPYX_SetMessageName_YXQP(IntPtr L_YXQP) { try { ToLua.CheckArgsCount(L_YXQP, 3); DNet.Buffer QPYX_obj_YXQP = (DNet.Buffer)ToLua.CheckObject <DNet.Buffer>(L_YXQP, 1); CDecompress QPYX_arg0_YXQP = (CDecompress)ToLua.CheckObject <CDecompress>(L_YXQP, 2); string QPYX_arg1_YXQP = ToLua.CheckString(L_YXQP, 3); QPYX_obj_YXQP.SetMessageName(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
/// <summary> /// Called when the web socket is open, and we are ready to send and receive data /// </summary> void OnOpen(WebSocket ws) { if (GameConfigProject.instance.netClientStateLogShow) { Debug.Log(string.Format("<color=#CC99CC>WebSocket【{0}】 Open! </color>", clientName)); } if (msgProtocolType == 2) { msgDataDecompresser = new CDecompress(); } if (onEventChangeFn != null) { onEventChangeFn.Call(NetWorkState.Connected.ToString()); } }
static int SetMessageName(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); DNet.Buffer obj = (DNet.Buffer)ToLua.CheckObject <DNet.Buffer>(L, 1); CDecompress arg0 = (CDecompress)ToLua.CheckObject <CDecompress>(L, 2); string arg1 = ToLua.CheckString(L, 3); obj.SetMessageName(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// Called when the web socket is open, and we are ready to send and receive data /// </summary> void OnOpen(WebSocket ws) { if (GameConfigProject.instance.netClientStateLogShow) { Debug.Log(string.Format("<color=#CC99CC>WebSocket【{0}】 Open! </color>", clientName)); } if (msgProtocolType == 2) { msgDataDecompresser = new CDecompress(); } try { if (onEventChangeFn != null) { onEventChangeFn.Call(NetWorkState.Connected.ToString()); } } catch (System.Exception ex) { // BuglyAgent.ReportException(ex, "WebSocketNetClient OnOpen"); Debug.LogException(ex); } }
public VideoData GetPlayBackInfo(byte[] Buffer_) { videoData = new VideoData(); int offSet = 0; //游戏版本号 byte[] versionByte = new byte[4]; versionByte[0] = Buffer_[offSet]; versionByte[1] = Buffer_[offSet + 1]; versionByte[2] = Buffer_[offSet + 2]; versionByte[3] = Buffer_[offSet + 3]; uint version = BitConverter.ToUInt32(versionByte, 0); byte[] gzLengthByte = new byte[2]; uint gzLength = 0; if (version != 1) { gzLengthByte[0] = Buffer_[offSet]; gzLengthByte[1] = Buffer_[offSet + 1]; gzLength = BitConverter.ToUInt16(gzLengthByte, 0); byte[] headData = new byte[gzLength]; Array.Copy(Buffer_, offSet + 2, headData, 0, gzLength); videoData.headData = headData; } else { offSet += 4; gzLengthByte[0] = Buffer_[offSet]; gzLengthByte[1] = Buffer_[offSet + 1]; gzLength = BitConverter.ToUInt16(gzLengthByte, 0); //规则,如人数、等等 byte[] gzStrByte = new byte[gzLength]; Array.Copy(Buffer_, offSet + 2, gzStrByte, 0, gzLength); videoData.rule = System.Text.Encoding.UTF8.GetString(gzStrByte); } offSet += (int)gzLength + 2; CDecompress cd = new CDecompress(); while (true) { byte[] HeadByte = new byte[2]; HeadByte[0] = Buffer_[offSet]; HeadByte[1] = Buffer_[offSet + 1]; ushort length_ = BitConverter.ToUInt16(HeadByte, 0); byte[] BodyByte = new byte[length_]; Array.Copy(Buffer_, offSet += 2, BodyByte, 0, length_); offSet += length_; uint length__ = 0; uint jbz = 0; cd.PreDecompress(BodyByte, out length__, out jbz); byte[] GS = new byte[length__]; cd.Decompress(BodyByte, ref GS); videoData.frames.Add(new VideoFrameData(GS)); if (offSet == Buffer_.Length) { break; } else if (offSet >= Buffer_.Length) { Debug.Log("解析出问题了 offSet: " + offSet + " Buffer_.Length: " + Buffer_.Length); break; } } return(videoData); }
//重置MsgData public void ResetMsgDataDecompresser() { msgDataDecompresser = new CDecompress(); }