Loading
 
I am doing move data from old version to new version base on nopcommerce

pubsub services with c-sharp, sample socket for server and client full source code


full source code download here 

simple and light weight pub sub write in c#
subcriber and channel, message passing is plain text

class PubSubServices : main data store (subcribers, channel, messages)

 var channelKey = "du";

            PubSubServices.Instance.Subcribe("subcriber_a", channelKey, s =>
            {
                Console.WriteLine("subcriber_a" + s);
                return true;
            });

            PubSubServices.Instance.Subcribe("subcriber_b", channelKey, s =>
            {
                Console.WriteLine("subcriber_b" + s);
                return true;
            });

            PubSubServices.Instance.Subcribe("subcriber_e", channelKey, s =>
            {
                Console.WriteLine("eror " + s);
                return false;
            });

          
                PubSubServices.Instance.Publish(channelKey, "hello " + DateTime.Now);


class PubSubSocketServer: provide upd socket server to subcribe or publish...

class Program
    {
        private static PubSubSocketServer _server;
        static void Main(string[] args)
        {
            _server = new PubSubSocketServer("127.0.0.1");
            _server.Report += _server_Report;
            _server.Start();

            Console.ReadLine();
        }

        private static void _server_Report(string obj)
        {
            Console.WriteLine(obj);
        }
    }


class PubSubSocketClient: provide client in c# to call pubpub socket serivices

string _ipserver = "127.0.0.1";
        int _portserver = 12345;   

PubSubSocketClient client = new PubSubSocketClient(_ipserver, _portserver);
            client.Ping();
            var channelKey = "http://badpaybad.info";
            client.Subcribe(channelKey, (msg) => { Console.WriteLine("client received -> " + msg); });
            var channelKey1 = "helloworld";
            client.Subcribe(channelKey1, (msg) => { Console.WriteLine("client received -> " + msg); });

            client.Publish(channelKey, "badpaybad.info said: sample pubsub with socket");
            client.Publish(channelKey1, "Xin chào bạn: " + DateTime.Now);



$0.00