private void CreateNewACWinConnection() { NetStream = null; client_tcpClient = new TcpClient(); int OLE_Port = 54700; try { RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Siemens\\ACWin\\IP\\Connection"); if (key != null) { OLE_Port = PhoneNumberManager.Int32Parse((string)key.GetValue("socket-port-ole-interface"), OLE_Port); key.Close(); } this.client_tcpClient.Connect("localhost", OLE_Port); } catch { // Log error that we were not able to connect to the server client_tcpClient = null; if (CounterStopReportingConnectionRetry > 0) { Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, "Could not connect to ACWin using connection details localhost:" + OLE_Port.ToString()); CounterStopReportingConnectionRetry--; } return; } NetStream = client_tcpClient.GetStream(); NetStream.ReadTimeout = 1000; //1 second timeout should be plenty //initialize the AVWinConnection InitializeACWinConnection(); }
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; } ; }