MCPcopy Create free account
hub / github.com/SoarGroup/Soar / CreateRemoteConnection

Method CreateRemoteConnection

Core/ClientSML/src/sml_ClientKernel.cpp:792–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792Kernel* Kernel::CreateRemoteConnection(bool sharedFileSystem, char const* pIPaddress, int port, bool ignoreOutput)
793{
794 ErrorCode errorCode = 0 ;
795
796 /* -- Create Soar_Instance and Output_Manager singletons -- */
797 Soar_Instance* lSoarInstance = instantiate_singletons();
798
799 // Initialize the socket library before attempting to create a connection
800 sock::SocketLib* pLib = new sock::SocketLib() ;
801
802 // Connect to the remote socket
803 Connection* pConnection = Connection::CreateRemoteConnection(sharedFileSystem, pIPaddress, port, &errorCode) ;
804
805 // Even if pConnection is NULL, we still build a kernel object, so we have
806 // a clean way to pass the error code back to the caller.
807 Kernel* pKernel = new Kernel(pConnection) ;
808 lSoarInstance->init_Soar_Instance(pKernel);
809
810 pKernel->SetSocketLib(pLib) ;
811 pKernel->SetError(errorCode) ;
812
813 // If this client isn't interested in getting output we can speed things up a bit for them.
814 pKernel->m_bIgnoreOutput = ignoreOutput ;
815
816 // If we had an error creating the connection, abort before
817 // we try to get the current agent list
818 if (pKernel->HadError())
819 {
820 return pKernel ;
821 }
822
823 // Register for "calls" from the kernel.
824 pConnection->RegisterCallback(ReceivedCall, pKernel, sml_Names::kDocType_Call, true) ;
825
826 // Register for important events
827 pKernel->InitEvents() ;
828
829 // Initialize our time tags
830 pKernel->InitializeTimeTagCounter() ;
831
832 // Get the current list of active agents
833 pKernel->UpdateAgentList() ;
834
835 return pKernel ;
836}
837
838/*************************************************************
839* @brief Returns the number of agents (from our list of known agents).

Callers 2

TestRemoteMethod · 0.95
remoteConnectMethod · 0.95

Calls 8

instantiate_singletonsFunction · 0.85
init_Soar_InstanceMethod · 0.80
RegisterCallbackMethod · 0.80
InitEventsMethod · 0.80
UpdateAgentListMethod · 0.80
SetErrorMethod · 0.45
HadErrorMethod · 0.45

Tested by 1

TestRemoteMethod · 0.76