public void LogPacket(byte [] Pkt, bool ClientSending) { if (((int)LogToFile & (int)LogLevels.LogFlagNetwork) == 0) { return; } BLFWinNoEnvelopHeader pkt = new BLFWinNoEnvelopHeader(); pkt = NetworkPacketTools.ByteArrayToStructure <BLFWinNoEnvelopHeader>(Pkt); StringBuilder sb = new StringBuilder(); if (ClientSending) { sb.Append("CMSG"); } else { sb.Append("SMSG"); } sb.Append(", T " + DateTime.Now.ToLongTimeString() + ":" + (Environment.TickCount % 1000).ToString()); sb.Append(", PktSize " + pkt.Length); sb.Append(", CMD " + pkt.Type); sb.Append(", BYTES : " + BitConverter.ToString(Pkt).Replace("-", string.Empty)); sb.Append(", AsString : " + Encoding.ASCII.GetString(Pkt)); sb.Append("\n\n"); WriteQueue.Add(sb.ToString()); }
//OSFOURK-8927 public bool ReqSystemStatus() { ReqSystemSatusStr Msg = new ReqSystemSatusStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.REQSYSTEMSTATUS; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : REQSYSTEMSTATUS"); return(SendMessageToSocket(Msg)); }
//OSFOURK-6654 public bool DbChecksumRequest() { DbGetChkRequestStr Msg = new DbGetChkRequestStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.DBGET_CHK_REQUEST; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : DBGET_CHK_REQUEST"); return(SendMessageToSocket(Msg)); }
public bool QueryDeviceForwarding(string device) { QueryDeviceForwardingStr Msg = new QueryDeviceForwardingStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.QUERYDEVICEFORWARDING; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(device, Msg.Device); } Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : QUERYDEVICEFORWARDING, device " + device); return(SendMessageToSocket(Msg)); }
public bool MonitorStop(string xrefId) { MonitorStopStr Msg = new MonitorStopStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.MONITORSTOP; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(xrefId, Msg.XrefId); } Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : MONITORSTOP, xrefid " + xrefId); return(SendMessageToSocket(Msg)); }
public bool DBRequest(ushort chunk) { DbSendAckStr Msg = new DbSendAckStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.DBSEND_ACK; Msg.Chunk = chunk; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : DBSEND_ACK, chunk " + chunk.ToString()); return(SendMessageToSocket(Msg)); }
public bool MakeCall(string calling_device, string called_directory_number, short shPrompt) { MakeCallStr Msg = new MakeCallStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.MAKECALL; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(calling_device, Msg.Calling_device); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(called_directory_number, Msg.Called_directory_number); } Msg.ShPrompt = shPrompt; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : MAKECALL, device " + calling_device.ToString() + " dir number " + called_directory_number.ToString() + " shpromt " + shPrompt.ToString()); return(SendMessageToSocket(Msg)); }
public bool SetFeatureForwarding(string device, string fwd_dn, short type, short shOn) { SetFeatureForwardingStr Msg = new SetFeatureForwardingStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.SETFEATUREFORWARDING; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(device, Msg.Device); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(fwd_dn, Msg.Fwd_dn); } Msg.Type = type; Msg.ShOn = shOn; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : SETFEATUREFORWARDING, device " + device + " fwd_dn " + fwd_dn + " type " + type.ToString() + " shon " + shOn.ToString()); return(SendMessageToSocket(Msg)); }
public bool TransferCall(string held_device_id, string active_device_id, string held_call_id, string active_call_id) { TransferCallStr Msg = new TransferCallStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.TRANSFERCALL; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(held_device_id, Msg.Held_device_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(active_device_id, Msg.Active_device_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(held_call_id, Msg.Held_call_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(active_call_id, Msg.Active_call_id); } Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : TRANSFERCALL, held_device_id " + held_device_id + " active_device_id " + active_device_id + " held_call_id " + held_call_id + " active_call_id " + active_call_id); return(SendMessageToSocket(Msg)); }
public bool SnapshotDevice(string device) { SnapshotDeviceStr Msg = new SnapshotDeviceStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.SNAPSHOTDEVICE; Msg.END = 0x55; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(device, Msg.Device); } if (SendMessageToSocket(Msg)) { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : SNAPSHOTDEVICE, device " + device); return(true); } return(false); }
public bool SingleStepTransfer(string active_call_id, string active_device_id, string transfered_to_device_id, string pvt_uu_data, short pvt_uu_data_len) { SingleStepTransferStr Msg = new SingleStepTransferStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.SINGLESTEPTRANSFER; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(active_call_id, Msg.Active_call_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(active_device_id, Msg.Active_device_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(transfered_to_device_id, Msg.Transfered_to_device_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(pvt_uu_data, Msg.Pvt_uu_data); } Msg.Pvt_uu_data_len = pvt_uu_data_len; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : SINGLESTEPTRANSFER, active_call_id " + active_call_id.ToString() + " active_device_id " + active_device_id.ToString() + " transfer_to_device_id " + transfered_to_device_id.ToString() + " pvt_uu_data " + pvt_uu_data); return(SendMessageToSocket(Msg)); }
public bool ConsultationCall(string held_device_id, string called_device_id, string held_call_id, string pvt_uu_data, short pvt_uu_data_len) { ConsultationCallStr Msg = new ConsultationCallStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.CONSULTATIONCALL; unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(held_device_id, Msg.Held_device_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(called_device_id, Msg.Called_device_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(held_call_id, Msg.Held_call_id); } unsafe { NetworkPacketTools.StrinToBytes_MAX_STN_CHARNO(pvt_uu_data, Msg.Pvt_uu_data); } Msg.Pvt_uu_data_len = pvt_uu_data_len; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : CONSULTATIONCALL, held_device_id " + held_device_id + " called_device_id " + called_device_id + " Held_called_id " + held_call_id + " pvt_uu_data " + pvt_uu_data); return(SendMessageToSocket(Msg)); }
private unsafe void CallInfoResponse() { /* * 04.12.2018 11:53:23:268 ACWinMQ Socket 2 >00 00 00 1B 52 45 53 00 00 00 01 00 00 00 0C 53 < ....RES........S 00000000 * 04.12.2018 11:53:23:268 ACWinMQ Socket 2 >65 72 76 43 61 6C 6C 49 6E 66 6F 00 00 00 00 < ervCallInfo.... 00000010 */ byte[] buff = new byte[ConstantsACWin.MAX_BUFF + ConstantsACWin.MAX_BUFF]; int BytesWritten = 4; //leave space to write the length as first field BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.ACWIN_TYPE_RES, buff, BytesWritten, true, false); //packet type BytesWritten += NetworkPacketTools.IntoToByteArray(1, buff, BytesWritten); // reference ID BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.SERVICE_SERV_CALL_INFO, buff, BytesWritten, true, false); // command BytesWritten += NetworkPacketTools.IntoToByteArray(0, buff, BytesWritten); // NetworkPacketTools.IntoToByteArray(BytesWritten - 4, buff, 0); //update packet size SendPacket(buff, BytesWritten); }
private unsafe void InitializeACWinConnection( ) { byte [] buff = new byte[ConstantsACWin.MAX_BUFF + ConstantsACWin.MAX_BUFF]; int BytesWritten = 4; //leave space to write the length as first field BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.ACWIN_TYPE_REQ, buff, BytesWritten, false, false); //packet type BytesWritten += NetworkPacketTools.IntoToByteArray(1, buff, BytesWritten); // reference ID BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.ACWIN_CMD_INITIALIZE, buff, BytesWritten, true, false); // command BytesWritten += NetworkPacketTools.StrToByteArray("SOCACWTDI", buff, BytesWritten, true, false); // app name BytesWritten += NetworkPacketTools.IntoToByteArray(2 * ConstantsACWin.AC_PASSWORD_LENGTH_SOCKET * ConstantsACWin.NUM_MAX_BYTES_PER_CHAR_UTF8, buff, BytesWritten); //size of the extra content BytesWritten += NetworkPacketTools.StrToByteArray("ACWTDI", buff, BytesWritten, false, false, ConstantsACWin.AC_PASSWORD_LENGTH_SOCKET * ConstantsACWin.NUM_MAX_BYTES_PER_CHAR_UTF8); // user name BytesWritten += NetworkPacketTools.StrToByteArray("oMf9eb", buff, BytesWritten, false, false, ConstantsACWin.AC_PASSWORD_LENGTH_SOCKET * ConstantsACWin.NUM_MAX_BYTES_PER_CHAR_UTF8); // user passw // BytesWritten += NetworkPacketTools.StrToByteArray("1.0", ci.m_protocol, BytesWritten, true, false); // this is only written as response and not as request NetworkPacketTools.IntoToByteArray(BytesWritten - 4, buff, 0); //update packet size SendPacket(buff, BytesWritten); }
private unsafe void RegisterService() { /* * 04.12.2018 11:52:20:966 ACWinMQ Socket 2 >00 00 00 23 52 45 51 00 00 00 03 00 00 00 08 52 < ...#REQ........R 00000000 * 04.12.2018 11:52:20:966 ACWinMQ Socket 2 >65 67 69 73 74 65 72 00 00 00 0C 53 65 72 76 43 < egister....ServC 00000010 * 04.12.2018 11:52:20:966 ACWinMQ Socket 2 >61 6C 6C 49 6E 66 6F < allInfo 00000020 */ byte[] buff = new byte[ConstantsACWin.MAX_BUFF + ConstantsACWin.MAX_BUFF]; int BytesWritten = 4; //leave space to write the length as first field BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.ACWIN_TYPE_REQ, buff, BytesWritten, false, false); //packet type BytesWritten += NetworkPacketTools.IntoToByteArray(3, buff, BytesWritten); // reference ID BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.ACWIN_CMD_REGISTER, buff, BytesWritten, true, false); // command BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.SERVICE_SERV_CALL_INFO, buff, BytesWritten, true, false); // service name NetworkPacketTools.IntoToByteArray(BytesWritten - 4, buff, 0); //update packet size SendPacket(buff, BytesWritten); }
private unsafe void MakeCall(string Extension) { /* * 04.12.2018 11:53:17:331 ACWinMQ Socket 2 >00 00 00 21 52 45 51 00 00 00 02 00 00 00 0A 41 < ...!REQ........A 00000000 * 04.12.2018 11:53:17:331 ACWinMQ Socket 2 >43 4D 61 6B 65 43 61 6C 6C 00 00 00 04 31 31 30 < CMakeCall....110 00000010 * 04.12.2018 11:53:17:331 ACWinMQ Socket 2 >33 00 00 00 01 < 3.... 00000020 */ byte[] buff = new byte[ConstantsACWin.MAX_BUFF + ConstantsACWin.MAX_BUFF]; int BytesWritten = 4; //leave space to write the length as first field BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.ACWIN_TYPE_REQ, buff, BytesWritten, false, false); //packet type BytesWritten += NetworkPacketTools.IntoToByteArray(2, buff, BytesWritten); // reference ID BytesWritten += NetworkPacketTools.StrToByteArray(ConstantsACWin.SERVICE_AC_MAKE_CALL, buff, BytesWritten, true, false); // command BytesWritten += NetworkPacketTools.StrToByteArray(Extension, buff, BytesWritten, true, false); // the phone number we are going to call BytesWritten += NetworkPacketTools.IntoToByteArray(1, buff, BytesWritten); //call type NetworkPacketTools.IntoToByteArray(BytesWritten - 4, buff, 0); //update packet size Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "ACWin: Sending MakeCall for extension : " + Extension.ToString()); SendPacket(buff, BytesWritten); }
private bool ParseCallInfo(byte[] packet) { /* * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 09 9F 52 45 51 00 00 00 01 00 00 00 0C 53 < ....REQ........S 00000000 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >65 72 76 43 61 6C 6C 49 6E 66 6F 00 00 09 88 31 < ervCallInfo....1 00000010 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >31 30 33 00 00 00 00 00 00 00 00 00 00 00 00 00 < 103............. 00000020 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000030 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000040 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000050 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000060 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000070 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000080 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000090 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000000A0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000000B0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000000C0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000000D0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000000E0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000000F0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000100 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000110 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000120 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000130 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000140 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000150 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000160 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000170 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000180 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000190 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000001A0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000001B0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000001C0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000001D0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000001E0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000001F0 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000200 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000210 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000220 * 04.12.2018 11:53:23:264 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000230 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000240 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000250 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000260 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000270 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000280 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000290 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000002A0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000002B0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000002C0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000002D0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000002E0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000002F0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000300 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000310 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000320 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 < ...............P 00000330 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >69 73 74 61 20 42 61 63 73 69 00 00 00 00 00 00 < ista Bacsi...... 00000340 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000350 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000360 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000370 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000380 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000390 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000003A0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000003B0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000003C0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000003D0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000003E0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000003F0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000400 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000410 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000420 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000430 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000440 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000450 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000460 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000470 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000480 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000490 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000004A0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000004B0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000004C0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000004D0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000004E0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000004F0 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000500 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000510 * 04.12.2018 11:53:23:265 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000520 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000530 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000540 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000550 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000560 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000570 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000580 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000590 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000005A0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000005B0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000005C0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000005D0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000005E0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000005F0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000600 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000610 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000620 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000630 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000640 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000650 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000660 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000670 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000680 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000690 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000006A0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000006B0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000006C0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000006D0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000006E0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000006F0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000700 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000710 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000720 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000730 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000740 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000750 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000760 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000770 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000780 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000790 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000007A0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000007B0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000007C0 * 04.12.2018 11:53:23:266 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000007D0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000007E0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000007F0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000800 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000810 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000820 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000830 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000840 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000850 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000860 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000870 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000880 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000890 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000008A0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000008B0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000008C0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000008D0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000008E0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 000008F0 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000900 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000910 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000920 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000930 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000940 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000950 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000960 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000970 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 01 00 00 00 0D 00 00 00 00 00 00 00 02 00 < ................ 00000980 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 < ................ 00000990 * 04.12.2018 11:53:23:267 ACWinMQ Socket 2 >00 00 00 < ... 000009A0 */ int BytesRead = 0; // read 4 bytes : size of packet if (BytesRead + 4 >= packet.Length) { return(false); } // int PacketSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 3 bytes : "RES" if (BytesRead + 3 >= packet.Length) { return(false); } string ResStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, 3); if (ResStr != ConstantsACWin.ACWIN_TYPE_REQ) { return(false); } BytesRead += 3; // read 4 bytes : reference id if (BytesRead + 4 >= packet.Length) { return(false); } // int ReferenceId = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 4 bytes : size of string if (BytesRead + 4 >= packet.Length) { return(false); } int ServerCallInfoStrSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read X bytes : string if (BytesRead + ServerCallInfoStrSize >= packet.Length) { return(false); } string ServerCallInfoStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, ServerCallInfoStrSize); if (ServerCallInfoStr != ConstantsACWin.SERVICE_SERV_CALL_INFO) { return(false); } BytesRead += ServerCallInfoStrSize; // read 4 bytes : size of rest of the packet if (BytesRead + 4 >= packet.Length) { return(false); } int PacketSize2 = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read X bytes : extension string // ..................... return(true); }
private unsafe bool ParseResponseRegister(byte[] packet) { /* * 04.12.2018 11:52:20:967 ACWinMQ Socket 2 >00 00 00 17 52 45 53 00 00 00 03 00 00 00 08 52 < ....RES........R 00000000 * 04.12.2018 11:52:20:967 ACWinMQ Socket 2 >65 67 69 73 74 65 72 00 00 00 01 < egister.... 00000010 */ int BytesRead = 0; // read 4 bytes : size of packet if (BytesRead + 4 >= packet.Length) { return(false); } int PacketSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 3 bytes : "RES" if (BytesRead + 3 >= packet.Length) { return(false); } string ResStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, 3); if (ResStr != ConstantsACWin.ACWIN_TYPE_RES) { return(false); } BytesRead += 3; // read 4 bytes : reference id if (BytesRead + 4 >= packet.Length) { return(false); } BytesRead += 4; // read 4 bytes : size of string if (BytesRead + 4 >= packet.Length) { return(false); } int RegisterStrSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read X bytes : string if (BytesRead + RegisterStrSize >= packet.Length) { return(false); } string RegisterStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, RegisterStrSize); if (RegisterStr != ConstantsACWin.ACWIN_CMD_REGISTER) { return(false); } BytesRead += RegisterStrSize; // read 4 bytes : size of string if (BytesRead + 4 > packet.Length) { return(false); } int ServiceType = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; return(true); }
public void InterpretMessage(byte [] ReceivedBytes2) { BLFWinNoEnvelopHeader pkt = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <BLFWinNoEnvelopHeader>(ReceivedBytes2); switch (pkt.Type) { case PacketTypes.ON_CONNECTED: { //update UI and say that we are online if (App.Current != null && App.Current.MainWindow != null) { (App.Current.MainWindow as MainWindow).OnServerConnectionChanged(true); } Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, "CBLF_w32Dlg::ConnectionOpened"); } break; case PacketTypes.ON_DISCONNECTED: { //update UI and say that we are offline if (App.Current != null && App.Current.MainWindow != null) { (App.Current.MainWindow as MainWindow).OnServerConnectionChanged(false); } Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, "CBLF_w32Dlg::ConnectionClosed"); } break; case PacketTypes.SYSTEMSTATUSSERVICEREQUEST: { SystemStatusServiceRequestStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <SystemStatusServiceRequestStr>(ReceivedBytes2); SystemStatusCodes ssc = (SystemStatusCodes)(pkt2.Type); if (ssc == SystemStatusCodes.SystemStatus_Search_DeadClient) { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status System_Status_DUMMY: " + pkt2.Type + " SystemStatus_Search_DeadClient "); } else if ((ssc == SystemStatusCodes.SystemStatus_normal || ssc == SystemStatusCodes.SystemStatus_initializing)) { //Write the problem to the log Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status System_Status_OK: " + pkt2.Type + " SystemStatus_normal/SystemStatus_initializing "); //notify connection manager that the server is up and running // Globals.ConnectionManager.OnHeartbeatReceived(); Globals.ExtensionManager.OnSystemStatusOk(nclient.ServerIPAndPort); // we presume that all monitors function correctly and no need to panic for lack of updates // m_bDisconnected_From_Callbridge = FALSE; //Hide the server problem window //Hide the server OK window //Hide the Connection problem problem window //Hide the Callbridge OK window //Hide the Callbridge problem window //Start a timer , but this timer will not work if the connection is ok,because //we killing it before the running //Starting a timer to reconnect if needed } else if (ssc == SystemStatusCodes.SystemStatus_disabled) { //Write the problem to the log Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status System_Status_Disabled: " + pkt2.Type); //Open the switch problem dialog //update status bar } else { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status:" + pkt2.Type); } // m_pWnd->SystemStatusService(pStruct->Type); break; } case PacketTypes.UNIVERSALERRORRESPONSE: { UniversalErrorResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <UniversalErrorResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); string errorCategory = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.ErrorCategory); string errorValue = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.ErrorValue); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : UNIVERSALERRORRESPONSE : device=" + device + ", ErrCat=" + errorCategory + ", Err=" + errorValue); //make sure we set the status of this device if (errorCategory == "Operation" && errorValue == "invalidDeviceID") { Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodes.PHONE_DOESNOT); } else if (errorCategory == "System Resource Availability" && errorValue == "deviceOutOfService") { Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodes.OutOfService); } // m_pWnd->UniversalErrorResponse(device, errorCategory, errorValue); } break; } case PacketTypes.SETFEATUREFORWARDINGRESPONSE: //nothing to do here { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SETFEATUREFORWARDINGRESPONSE"); //?! missing in CSink break; } case PacketTypes.QUERYDEVICEFORWARDINGRESPONSE: //nothing to do here { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : QUERYDEVICEFORWARDINGRESPONSE"); //?! missing in CSink break; } case PacketTypes.CONSULTATIONCALLRESPONSE: { ConsultationCallResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <ConsultationCallResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); string callId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CallID); string deviceId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DeviceID); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : CONSULTATIONCALLRESPONSE Device=" + device + " CallId=" + callId + " DeviceId=" + deviceId); // m_pWnd->ConsultationCallResponse(device, callId, deviceId); /// !!!!!!!!!!! not finished if (Globals.Config.GetConfig("Options", "Optiset", "NO") == "YES") { string OptiSet = Globals.Config.GetConfig("Options", "OptisetExtension", ""); //get the extension only from a full phone number string OptisetExtenstion = PhoneNumber.GetExtensionFromFullNumberStr(OptiSet); long CallId = Globals.ExtensionManager.GetCallId(nclient.ServerIPAndPort, null, OptisetExtenstion); if (OptisetExtenstion == device) { if (nclient != null) { nclient.PacketBuilder.TransferCall(OptisetExtenstion, OptisetExtenstion, CallId.ToString(), callId); } } } } break; } case PacketTypes.TRANSFERCALLRESPONSE: //nothing to do here { TransferCallResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <TransferCallResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : TRANSFERCALLRESPONSE for device " + device); // Globals.AppVars.m_bConsultationCall = false; // Globals.AppVars.m_strDeviceIDTemp = ""; // Globals.AppVars.m_strCallIDTemp = ""; // BP-3.0.9.0-050816: Feature 'CallID as string': Modified: long m_lCallIDTemp -> CString m_strCallIDTemp // m_pWnd->TransferCallResponse(device); } break; } case PacketTypes.SINGLESTEPTRANSFERRESPONSE: //nothing to do here { SingleStepTransferResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <SingleStepTransferResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SINGLESTEPTRANSFERRESPONSE " + device); // m_pWnd->SingleStepTransferResponse(device); } break; } case PacketTypes.MAKECALLRESPONSE: //nothing to do here { MakeCallResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MakeCallResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MAKECALLRESPONSE for device " + device); // m_pWnd->MakeCallResponse(device); } break; } case PacketTypes.UPDATEDEVICESTATE: //nothing to do here { UpdateDeviceStateStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <UpdateDeviceStateStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : UPDATEDEVICESTATE " + device + " " + pkt2.State.ToString()); PhoneStatusCodes code = PhoneStatusCodeTranslateMonitor(pkt2.State); if (code < PhoneStatusCodes.NumberOfStatusCodes) { Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, code); } //mark this extension as valid on this server. Some extensions might exist on more than 1 server if (code == PhoneStatusCodes.Busy || code == PhoneStatusCodes.Idle || code == PhoneStatusCodes.PHONE_EXTERNAL || code == PhoneStatusCodes.Ringing) { PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device); } // m_pWnd->UpdateDeviceState(device,pkt2.state); } break; } case PacketTypes.ESTABLISHEDEVENT: { EstablishedEventStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <EstablishedEventStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); string callId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CallId); string deviceId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DeviceId); string answeringDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.AnsweringDevice); string callingDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CallingDevice); string calledDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CalledDevice); string lastRedirectionDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.LastRedirectionDevice); short isExternal = pkt2.shExternal; //OSFOURK-6659 Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : ESTABLISHEDEVENT" + " Device=" + device + " CallId=" + callId + " DeviceId=" + deviceId + " AnswerDevice=" + answeringDevice + " CallingDevice=" + callingDevice + " CalledDevice=" + calledDevice + " LastRedirectionDevice=" + lastRedirectionDevice + " IsExternal=" + isExternal.ToString()); Globals.ExtensionManager.OnCallIdReceived(nclient.ServerIPAndPort, null, callingDevice, callId, calledDevice); //m_pWnd->EstablishedEvent(device, callId, deviceId, answeringDevice, callingDevice, calledDevice, lastRedirectionDevice, isExternal); /* if (device == Globals.Config.GetConfig("Options", "OptisetExtension", "")) * { * Globals.AppVars.m_strDeviceIDTemp = deviceId; * Globals.AppVars.m_strCallIDTemp = callId; * } * if((device == Globals.Config.GetConfig("Options", "OptisetExtension", "") || device == Globals.ExtensionManager.GetLastSelectedExtension().ToString()) && Globals.AppVars.m_bConsultationCall == true) * { * Globals.AppVars.m_bConsultationCall = false; * Globals.AppVars.m_strDeviceIDTemp = ""; * Globals.AppVars.m_strCallIDTemp = ""; // BP-3.0.9.0-050816: Feature 'CallID as string': Modified: long m_lCallIDTemp -> CString m_strCallIDTemp * }*/ if (isExternal == ServerSidePhoneStatusCodes.ZS_EXTERNVERBINDUNG) { Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodeTranslate(ServerSidePhoneStatusCodes.ZS_EXTERNAL)); } else { Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodeTranslate(ServerSidePhoneStatusCodes.ZS_GESPRAECH)); } } break; } case PacketTypes.CONNECTIONCLEAREDEVENT: { ConnectionClearedEventStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <ConnectionClearedEventStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); string droppedCall = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DroppedCall); string droppedDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DroppedDevice); string releasingDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.ReleasingDevice); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : CONNECTIONCLEAREDEVENT Device=" + device + " CallId=" + droppedCall + " DroppedDevice=" + droppedDevice + " ReleasingDevice=" + releasingDevice + " State=" + pkt2.shLocalConnectionState.ToString() + " Cause=" + pkt2.shEventCause.ToString()); Globals.ExtensionManager.OnCallIdClear(nclient.ServerIPAndPort, null, device, droppedCall, droppedDevice); //m_pWnd->ConnectionClearedEvent(device, droppedCall, droppedDevice, releasingDevice, pStruct->shLocalConnectionState, pStruct->shEventCause); PhoneStatusCodes code = PhoneStatusCodeTranslateMonitor(pkt2.shLocalConnectionState); if (code < PhoneStatusCodes.NumberOfStatusCodes) { Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, code); } else { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CONNECTIONCLEAREDEVENT : Ignore handling status update as not recognized state"); } } break; } case PacketTypes.UPDATEFORWARDSTATESTR: { UpdateForwardStateStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <UpdateForwardStateStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); string pvtFwdDn = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.pvt_fwd_dn); string pvtType = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.pvt_type); string Exntension = device; long Fwd = PhoneNumberManager.Int32Parse(pvtFwdDn, 0); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : UPDATEFORWARDSTATESTR, device " + device + " forward " + pvtFwdDn + " fwd type " + pvtType); if (Fwd != 0) { Globals.ForwardManager.PhoneNumberUpdateForwarding(Exntension, CallForwardingTypes.CallForwardDestination, 0, Fwd); } else { Globals.ForwardManager.PhoneNumberUpdateForwarding(Exntension, CallForwardingTypes.CallForwardNone, 0, Fwd); } PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device); } break; } case PacketTypes.NETWORKREACHEDEVENT: { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : NETWORKREACHEDEVENT"); NetworkReachedEventStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <NetworkReachedEventStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); string calledDeviceId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.called_device_id); //m_pWnd->NetworkReached(device, calledDeviceId); //folders[i]->UpdateCell(_T((char*)bstrDevice), ZS_EXTERNAL, dc); Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodeTranslate(ServerSidePhoneStatusCodes.ZS_EXTERNAL)); } break; } case PacketTypes.MONITORSTARTRESPONSE: //nothing to do here { MonitorStartResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStartResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); string xRef = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Xref); Globals.ExtensionManager.OnMonitorStart(nclient.ServerIPAndPort, null, device, xRef); //m_pWnd->MonitorStartResult(device, xRef); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MONITORSTARTRESPONSE , device " + device + ", xref " + xRef); PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device); } break; } case PacketTypes.MONITORSTOPRESPONSE: //nothing to do here { MonitorStopResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStopResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); Globals.ExtensionManager.OnMonitorStop(nclient.ServerIPAndPort, null, device); //m_pWnd->MonitorStopResult(); Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MONITORSTOPRESPONSE, device " + device); } break; } case PacketTypes.SNAPSHOTDEVICERESPONSE: { // Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SNAPSHOTDEVICERESPONSE"); SnapshotDeviceResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <SnapshotDeviceResponseStr>(ReceivedBytes2); unsafe { string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device); //m_pWnd->SnapshotDeviceResult(device, pStruct->State); PhoneStatusCodes code = PhoneStatusCodeTranslate(pkt2.State); if (code < PhoneStatusCodes.NumberOfStatusCodes) { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SNAPSHOTDEVICERESPONSE : device '" + device + "', state '" + pkt2.State + "'"); Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, code); PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device); } else { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SNAPSHOTDEVICERESPONSE : !Ignored! : device '" + device + "', state '" + pkt2.State + "'"); } } break; } case PacketTypes.MONITORSTOPREQUEST: { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MONITORSTOPREQUEST"); MonitorStopRequestStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStopRequestStr>(ReceivedBytes2); unsafe { string xrefId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.XREFId); //m_pWnd->MonitorStopRequest(xrefId); Globals.ExtensionManager.OnMonitorStop(nclient.ServerIPAndPort, null, xrefId); } break; } case PacketTypes.DIVERTEDEVENT: { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : DIVERTEDEVENT"); MonitorStopRequestStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStopRequestStr>(ReceivedBytes2); unsafe { string xrefId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.XREFId); PhoneNumber pn = Globals.ExtensionManager.PhoneNumberGetByXRef(nclient.ServerIPAndPort, PhoneNumberManager.Int32Parse(xrefId, 0)); if (pn != null) { if (pn.GetStatus() == PhoneStatusCodes.Ringing) { if (App.Current != null) { App.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { MainWindow MainObject = (MainWindow)App.Current.MainWindow; if (MainObject == null) { return; } pn.SetStatus(PhoneStatusCodes.Idle); })); } } } else { // create a new store and set the state as idle // this is not required for us (i think). We will query the state as soon as we have a store for it } //m_pWnd->DivertedEvent(xrefId); } break; } case PacketTypes.DBSENDCHK: { //OSFOURK-6654 Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : DBSENDCHK"); DbSendChkStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <DbSendChkStr>(ReceivedBytes2); ushort checksum = pkt2.Xchk; ushort ClientChecksum = Globals.persPortManager.GetChecksum(nclient.ServerIPAndPort); //m_pWnd->ValidateChksum(checksum); if (ClientChecksum != checksum) { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " Checksum mismatch, will request a new persport"); if (nclient != null) { nclient.PacketBuilder.DBRequest((ushort)0xffff); } } else { Globals.persPortManager.ReParsePersportTXT(nclient.ServerIPAndPort); Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, nclient.ServerIPAndPort + " Checksum says persport is up to date"); } break; } case PacketTypes.DBCHUNK: { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : DBCHUNK"); DbChunkHdrStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <DbChunkHdrStr>(ReceivedBytes2); ushort maxChunk = pkt2.MaxChunk; ushort chunk = pkt2.Chunk; int HeaderSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(DbChunkHdrStr)); int chunkLen = pkt2.Size - HeaderSize + 2; // no idea from where that extra 2 comes from. As long as it works ... //save the chunk Globals.persPortManager.SaveChunkToFile(chunk, ReceivedBytes2, HeaderSize, chunkLen, nclient.ServerIPAndPort); //request the next chunk to be saved if (chunk < maxChunk) { if (nclient != null) { nclient.PacketBuilder.DBRequest(chunk); } } else { Globals.persPortManager.ReParsePersportTXT(nclient.ServerIPAndPort); Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "Fetched all " + maxChunk.ToString() + " chunks of passport.txt"); } break; } default: { // unhandled packet type Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : Unknown and unhandled, type " + pkt.Type.ToString() + " length " + pkt.Length.ToString()); } break; } ; }
private unsafe bool ParseResponseInitialize(byte[] packet) { /* * 04.12.2018 11:52:20:965 ACWinMQ Socket 2 >00 00 00 27 52 45 53 00 00 00 01 00 00 00 0A 49 < ...'RES........I 00000000 * 04.12.2018 11:52:20:965 ACWinMQ Socket 2 >6E 69 74 69 61 6C 69 7A 65 00 00 00 0A 56 32 20 < nitialize....V2 00000010 * 04.12.2018 11:52:20:965 ACWinMQ Socket 2 >52 34 2E 31 30 2E 30 00 00 00 00 < R4.10.0.... 00000020 */ int BytesRead = 0; // read 4 bytes : size of packet if (BytesRead + 4 >= packet.Length) { return(false); } // int PacketSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 3 bytes : "RES" if (BytesRead + 3 >= packet.Length) { return(false); } string ResStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, 3); if (ResStr != ConstantsACWin.ACWIN_TYPE_RES) { return(false); } BytesRead += 3; // read 4 bytes : reference id if (BytesRead + 4 >= packet.Length) { return(false); } // int ReferenceId = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 4 bytes : size of string if (BytesRead + 4 >= packet.Length) { return(false); } int InitializeStrSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read X bytes : string if (BytesRead + InitializeStrSize >= packet.Length) { return(false); } string InitializeStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, InitializeStrSize); if (InitializeStr != ConstantsACWin.ACWIN_CMD_INITIALIZE) { return(false); } BytesRead += InitializeStrSize; // read 4 bytes : size of string if (BytesRead + 4 >= packet.Length) { return(false); } int VersionStrSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read X bytes : string if (BytesRead + VersionStrSize > packet.Length) { return(false); } // string VersionStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, VersionStrSize); BytesRead += VersionStrSize; return(true); }
/// <summary> /// Queue a packet for sending. Queued packet are sent as a bytestream. Might not be 1 packet / send ! /// </summary> /// <param name="p"></param> public void SendPacket(object p) { //create a byte array out of the packet and queue it to the sender thread WriteQueue.Add(NetworkPacketTools.StructureToByteArray(p)); }
private unsafe bool ParseResponseMakeCall(byte[] packet) { /* * 04.12.2018 11:53:17:511 ACWinMQ Socket 2 >00 00 00 19 52 45 53 00 00 00 02 00 00 00 0A 41 < ....RES........A 00000000 * 04.12.2018 11:53:17:511 ACWinMQ Socket 2 >43 4D 61 6B 65 43 61 6C 6C 00 00 00 00 < CMakeCall.... 00000010 */ int BytesRead = 0; // read 4 bytes : size of packet if (BytesRead + 4 >= packet.Length) { return(false); } int PacketSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 3 bytes : "RES" if (BytesRead + 3 >= packet.Length) { return(false); } string ResStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, 3); if (ResStr != ConstantsACWin.ACWIN_TYPE_RES) { return(false); } BytesRead += 3; // read 4 bytes : reference id if (BytesRead + 4 >= packet.Length) { return(false); } BytesRead += 4; if (BytesRead >= packet.Length) { return(false); } // read 4 bytes : size of string if (BytesRead + 4 >= packet.Length) { return(false); } int RegisterStrSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; if (BytesRead >= packet.Length) { return(false); } // read X bytes : string if (BytesRead + RegisterStrSize >= packet.Length) { return(false); } string RegisterStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, RegisterStrSize); if (RegisterStr != ConstantsACWin.SERVICE_AC_MAKE_CALL) { return(false); } BytesRead += RegisterStrSize; // read 4 bytes : size of string if (BytesRead + 4 > packet.Length) { return(false); } int StatusType = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "ACWin: Received MakeCall reply code : " + StatusType.ToString()); return(true); }
public bool AliveTest(long newState) { AliveTestStr Msg = new AliveTestStr(); Msg.BEG = 0xaa; Msg.Size = (short)(System.Runtime.InteropServices.Marshal.SizeOf(Msg) - NetworkPacketTools.PCK_HDR_TRM_LEN()); Msg.Cmd = PacketTypes.ALIVETEST; Msg.NewState = newState; Msg.END = 0x55; Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CMSG : ALIVETEST, new state " + newState.ToString()); return(SendMessageToSocket(Msg)); }
private unsafe bool ParseResponseError(byte[] packet) { /* * 04.12.2018 18:05:37:568 ACWinMQ Socket 2 >00 00 00 14 45 52 52 00 00 00 01 00 00 00 05 45 < ....ERR........E 00000000 * 04.12.2018 18:05:37:568 ACWinMQ Socket 2 >72 72 6F 72 00 00 00 00 < rror.... 00000010 */ int BytesRead = 0; // read 4 bytes : size of packet if (BytesRead + 4 >= packet.Length) { return(false); } // int PacketSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 3 bytes : "ERR" if (BytesRead + 3 >= packet.Length) { return(false); } string ResStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, 3); if (ResStr != ConstantsACWin.ACWIN_TYPE_ERR) { return(false); } BytesRead += 3; // read 4 bytes : reference id if (BytesRead + 4 >= packet.Length) { return(false); } // int ReferenceId = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read 4 bytes : size of string if (BytesRead + 4 >= packet.Length) { return(false); } int ErrorStrSize = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; // read X bytes : string if (BytesRead + ErrorStrSize >= packet.Length) { return(false); } string ErrorStr = NetworkPacketTools.ByteArrayToStr(packet, BytesRead, ErrorStrSize); if (ErrorStr != ConstantsACWin.ACWIN_CMD_GENERAL_ERROR) { return(false); } BytesRead += ErrorStrSize; // read 4 bytes : if (BytesRead + 4 >= packet.Length) { return(false); } int SomeValue = NetworkPacketTools.ByteArrayToInt(packet, BytesRead); BytesRead += 4; return(true); }
private void PeriodicUpdate(object source) { if (Monitor.TryEnter(this)) { //are you sure we should be still using ACWin connection ? if (Globals.Config.GetConfig("Options", "ACWin", "NO") != "YES") { Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "Disabled ACWin connection manager. Config file changed while program was running"); UpdateTimer.Dispose(); Monitor.Exit(this); return; } //check if we have a working connection. If not yet, try to create a new one if (client_tcpClient == null || client_tcpClient.Connected == false) { CreateNewACWinConnection(); } //if we failed to create a connection, bail out if (client_tcpClient == null || client_tcpClient.Connected == false) { if (CounterStopReportingConnectionRetry > 0) { Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "Failed to create ACWin connection"); CounterStopReportingConnectionRetry--; } Monitor.Exit(this); return; } else { CounterStopReportingConnectionRetry = 1; } //something must have went very wrong if we are missing a stream if (NetStream == null) { Monitor.Exit(this); return; } //new packet ? Read size for it if (PacketSizeCur == 0) { //check if we have packets to read byte[] SizeBytes = new byte[4]; try { int ReadCount = NetStream.Read(SizeBytes, 0, 4); if (ReadCount == 4) { PacketSizeCur = NetworkPacketTools.ByteArrayToInt(SizeBytes, 0); PacketSizeRecv = 0; packet = new byte[PacketSizeCur + 4]; packet[0] = SizeBytes[0]; packet[1] = SizeBytes[1]; packet[2] = SizeBytes[2]; packet[3] = SizeBytes[3]; // Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, "ACWin recv : " + PacketSizeCur.ToString() + " bytes"); } } catch { }; } //incomplete packet ? Read some more for it if (PacketSizeRecv < PacketSizeCur) { int ReadCount = NetStream.Read(packet, 4, PacketSizeCur - PacketSizeRecv); PacketSizeRecv += ReadCount; //parse the packet } //complete packet ? Parse it if (PacketSizeRecv == PacketSizeCur) { OnPacketReceived(packet, PacketSizeCur); PacketSizeCur = 0; } Monitor.Exit(this); } }