示例#1
0
        private void StartServer()
        {
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            IDictionary props = new Hashtable();

            props["port"] = 8080;
            HttpChannel channel = new HttpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(channel, false);

            #region 客户端订阅服务端事件

            Obj = new BroadCastObj();
            ObjRef objRef = RemotingServices.Marshal(Obj, "BroadCastMessage.soap");

            #endregion

            #region 客户端订阅客户端事件

//			RemotingConfiguration.RegisterWellKnownServiceType(
//							typeof(BroadCastObj),"BroadCastMessage.soap",
//							WellKnownObjectMode.Singleton);

            #endregion
        }
示例#2
0
        /// <summary>
        /// 启动服务器
        /// </summary>
        public void StartServer()
        {
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            // 由config中读取相关数据
            string channelName = ConfigurationManager.AppSettings["ChannelName"];
            string channelType = ConfigurationManager.AppSettings["ChannelType"];
            string channelPort = ConfigurationManager.AppSettings["ChannelPort"];

            IDictionary props = new Hashtable();

            props["name"] = channelName;
            props["port"] = channelPort;
            TcpChannel channel = new TcpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(channel);

            // 客户端订阅服务端广播事件
            // 将远程对象推送到通道中,这样就可以让客户端进行访问
            Obj = new BroadCastObj();
            ConnectBroadCastObj();

            // 客户端访问地址注册
            RegisterClientRemoteObjServiceType();
            // 订阅客户端事件
            RegisterClientRemoteObjEvents();


            State = (int)StateEnum.Running;
        }
示例#3
0
        // 初始化及配置
        private void StartServer()
        {
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            // 由config中读取相关数据
            string channelName       = ConfigurationManager.AppSettings["ChannelName"];
            string channelType       = ConfigurationManager.AppSettings["ChannelType"];
            string channelPort       = ConfigurationManager.AppSettings["ChannelPort"];
            string broadCastObjURI   = ConfigurationManager.AppSettings["BroadCastObjURI"];
            string upCastObjURI      = ConfigurationManager.AppSettings["UpCastObjURI"];
            string visUpCastObjURI   = ConfigurationManager.AppSettings["VisUpCastObjURI"];
            string moverUpCastObjURI = ConfigurationManager.AppSettings["MoverUpCastObjURI"];
            string robotUpCastObjURI = ConfigurationManager.AppSettings["RobotUpCastObjURI"];


            IDictionary props = new Hashtable();

            props["name"] = channelName;
            props["port"] = channelPort;
            TcpChannel channel = new TcpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(channel);

            // 客户端订阅服务端广播事件
            // 将远程对象推送到通道中,这样就可以让客户端进行访问
            Obj = new BroadCastObj();
            ObjRef objRef = RemotingServices.Marshal(Obj, broadCastObjURI);

            // 服务端订阅客户端事件
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(UpCastObj), upCastObjURI, WellKnownObjectMode.Singleton);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(VisUpCastObj), visUpCastObjURI, WellKnownObjectMode.Singleton);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(RobotUpCastObj), robotUpCastObjURI, WellKnownObjectMode.Singleton);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(MoverUpCastObj), moverUpCastObjURI, WellKnownObjectMode.Singleton);

            UpCastObj.UpCastEvent      += OnUpCastEvent;
            VisUpCastObj.UpCastEvent   += OnVisUpCastEvent;
            RobotUpCastObj.UpCastEvent += OnRobotUpCastEvent;
            MoverUpCastObj.UpCastEvent += OnMoverUpCastEvent;
        }
示例#4
0
        private void initServer()
        {
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

            IDictionary props = new Hashtable();

            props["port"] = 8080;
            HttpChannel channel = new HttpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(channel, false);

            #region 客户端订阅服务端事件

            Obj = new BroadCastObj();
            ObjRef objRef = RemotingServices.Marshal(Obj, "BroadCastMessage.soap");

            #endregion
        }