コード例 #1
0
        public void Go()
        {
            client              = new ClientSocket();
            client.OnConnected += new Sockets.OnConnectDelegate(OnConnected);
            client.OnReceived  += new Sockets.OnReceiveDelegate(OnReceived);

            client.AddReceiveEventHandler(typeof(EchoCommand), OnEcho);
            client.AddReceiveEventHandler(typeof(WhatTimeIsItCommand), OnWhatTimeIsIt);

            // use the xml buffer codec for this client endpoint.
            client.BufferCodec = new XmlBufferCodec();

            // NOTE that this will happen several times, since the Server and Client testing
            // is done in the same main running process, as such, multiple scanning will
            // happen, in a real-life program, this will not happen, since each process is
            // self contained, and should theoritically handle its own SET.
            client.BufferCodec.ScanForIdentity(
                "Pivotal.Core.NET",
                "^Pivotal.Core.NET.*Command$"
                );
            client.BufferCodec.ScanForIdentity(
                "Pivotal.Core.NET.TestServer",
                "^Pivotal.Core.NET.*Command$"
                );

            client.Connect("127.0.0.1", 8090);
        }