Exemple #1
0
        /// <summary>
        /// Constructor for the SimpleClient. Creates a client and initiates the connection procedure.
        /// </summary>
        /// <param name="serverAddress">Ip address of the OELib server to connect to</param>
        /// <param name="serverPort">Port of the OELib server to connect to</param>
        public SimpleClient(string serverAddress, int serverPort)
        {
            // Create a new PokingClientConnection
            _client = new PokingClientConnection(this);

            // Connect the client to the server
            _client.Start(serverAddress, serverPort);

            // When the client and server have agreed on which methods are supported it is possible to send objects to the other part.
            _client.Reactor.RemoteReactingInspectionComplete += (s, e) =>
            {
                Console.WriteLine("Connected to server.");
                //TestGenerics();
                //SendTestObjectToServer();
            };
        }
Exemple #2
0
        private static void TestFormatter(OELibProtobufFormatter.OELibProtobufFormatter serverFormatter, OELibProtobufFormatter.OELibProtobufFormatter clientFormatter,
                                          string formatterName, int port, string MethodName)
        {
            var sro    = new ReactingObject();
            var go     = new AutoResetEvent(false);
            var server =
                new PokingServer(port, sro, serverFormatter, null, false);

            server.Start();
            server.ClientConnected += (s, e) =>
            {
                //Console.WriteLine($"Client connected to the server, server formatter is {server.Formatter}.");
                go.Set();
                //e.PingInterval = 10000000;
                e.MessageReceived += (se, me) =>
                {
                    //Console.WriteLine($"Server got message {me.ToString()}.");
                };
            };

            var cro    = new ReactingObject();
            var client = new PokingClientConnection(cro, clientFormatter, null, false) /*PingInterval = 1000000 */ }
 public Client()
 {
     _client = new PokingClientConnection(this);
     _client.Start("127.0.0.1", 1024);
 }