Beispiel #1
0
        private void InitCluster()
        {
            m_clusterTCPServer = new TCPServer();
            m_tcpObjectContainer.Add(m_clusterTCPServer);

            m_clusterTCPClient = new TCPClient();
            m_tcpObjectContainer.Add(m_clusterTCPClient);

            ClusterServer_Init clusterServerInit = new ClusterServer_Init();

            clusterServerInit.tcp_server_id = m_clusterTCPServer.GetObjectId();
            int clusterServerId = SparkServerUtility.NewService("SparkServer.Framework.Service.ClusterServer.ClusterServer",
                                                                "clusterServer",
                                                                clusterServerInit.encode());

            ClusterClient_Init clusterClientInit = new ClusterClient_Init();

            clusterClientInit.tcp_client_id  = m_clusterTCPClient.GetObjectId();
            clusterClientInit.cluster_config = m_bootConfig["ClusterConfig"].ToString();
            int clusterClientId = SparkServerUtility.NewService("SparkServer.Framework.Service.ClusterClient.ClusterClient",
                                                                "clusterClient",
                                                                clusterClientInit.encode());

            m_clusterTCPServer.Start(m_clusterServerIp, m_clusterServerPort, 30, clusterServerId,
                                     OnSessionError, OnReadPacketComplete, OnAcceptComplete);
            m_clusterTCPClient.Start(clusterClientId, OnSessionError, OnReadPacketComplete, OnConnectedComplete);
        }