Exemplo n.º 1
0
        private void ConnectionServer()
        {
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            byte[] buffer = new byte[1024 * 1024];
            int    len    = 0;

            try
            {
                socket.Connect(IPAddress.Parse(ip), port);
                LogHelper.Info("connection service success!");

                //socket.Send(Encoding.UTF8.GetBytes("hello world!\n"));
                //发送消息
                socket.Send(Encoding.UTF8.GetBytes(info + "\n"));

                //连接处理
                ProcessAync(socket, buffer);

                MedivhConfig.ResetConnectionInterval();
            }
            catch (SocketException ex)
            {
                LogHelper.Error(ex);
                MedivhConfig.ConnectionInterval += 1;
            }
        }
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="config"></param>
 public static void Init(MedivhConfig config)
 {
     if (config == null)
     {
         throw new Exception("param config is null");
     }
     ConfigHelper.SetMedivhConfig(config);
     Init(config.Client, config.ServerIp, config.ServerPort);
 }
Exemplo n.º 3
0
        public static void Run()
        {
            //初始化日志记录器
            MedivhSdk.SetLogger(Log, 1);

            MedivhConfig config = new MedivhConfig();

            config.Client = new ClientInfo()
            {
                AppName = "消息中心监控测试NO1", AppKey = "aaaaaaaaaaaaaaaaaa", AppSecret = "..."
            };
            config.ServerIp   = "192.168.155.106";
            config.ServerPort = 5000;

            //初始化medivh引擎
            MedivhSdk.Init(config);

            //添加测试数据

            Test();
        }
 internal static void SetMedivhConfig(MedivhConfig c)
 {
     config = c;
 }