/// <summary>
        /// 网络 状态变化 处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void Communication_OnCommunicationStateChange(object sender, CommunicationStateChangeArgs args)
        {
            //根据通讯编号找驱动映射关系
            string driverCode = GatewayMapper.GetDriverCode(args.CommunicationCode);

            //交给驱动处理业务包
            GatewayManager.DriverManager.HandleCommunicationStateChange(driverCode, args);
        }
        //private CommunicationInfo GetBroadCastDefaultCommunication()
        //{
        //    //string netServerIp = Basic.Framework.Configuration.ConfigurationManager.FileConfiguration.GetString("BroadCastServerIp", "127.0.0.1");
        //    //int netServerPort = Basic.Framework.Configuration.ConfigurationManager.FileConfiguration.GetInt("BroadCastServerPort", 7300);

        //    //CommunicationInfo ci = new CommunicationInfo()
        //    //{
        //    //    CommunicationCode = "BC001",
        //    //    DriverCode = "",
        //    //    ServerIp = netServerIp,
        //    //    ServerPort = netServerPort,
        //    //    SocketType = SocketType.TCP,
        //    //    CommunicationType = CommunicationType.Http,
        //    //    DeviceList = new List<string>()
        //    //};
        //    //return ci;
        //}

        /// <summary>
        /// 收到网络数据处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void Communication_OnNetDataArrived(object sender, NetDataArrivedEventArgs args)
        {
            //根据通讯编号找驱动映射关系
            string driverCode = GatewayMapper.GetDriverCode(args.CommunicationCode);

            //交给驱动处理业务包
            GatewayManager.DriverManager.HandleNetData(driverCode, args.UniqueCode, args.Data);
        }
Beispiel #3
0
        /// <summary>
        /// Writes the gate to return to using a raw Guid. This should only be used when the game state is reset (e.g. loading from a file)
        /// </summary>
        /// <remarks>
        /// This method will cause a Gate resolution failure if an invalid Guid is used
        /// </remarks>
        /// <param name="guid">The Guid to write as the target</param>
        public void WriteTarget(System.Guid guid)
        {
            GatewayMapper.WritePreviousGate(this);
            GatewayMapper.WriteTargetGate(guid);

            _previousSceneIndex = SceneManager.GetActiveScene().buildIndex;

            _targetsOverriden = true;
        }
        /// <summary>
        /// 设备类请求处理
        /// </summary>
        /// <param name="rpcRequest"></param>
        /// <returns></returns>
        private RpcResponse HandleDeviceRequest(RpcRequest rpcRequest)
        {
            var masProtocol = rpcRequest.ToRequest <GatewayRpcRequest>().MasProtocol;
            //调用驱动 处理业务
            DeviceProtocol deviceProtocol = masProtocol.Deserialize <DeviceProtocol>();
            string         driverCode     = GatewayMapper.GetDriverCodeByDeviceCode(deviceProtocol.DeviceCode);

            GatewayManager.DriverManager.HandleProtocolData(driverCode, masProtocol);

            return(RpcResponse.Response <GatewayRpcResponse>(new GatewayRpcResponse()));
        }
Beispiel #5
0
        internal sealed override void WriteTargets()
        {
            if (_targetsOverriden)
            {
                return;
            }

            // a ReturnGate does not write a previous gate

            if (GatewayMapper.TryGetPreviousGuid(out System.Guid guid, out SceneReference scene))
            {
                GatewayMapper.WriteTargetGate(guid);
                _previousSceneIndex = scene.BuildIndex;
            }
            else
            {
                throw new GateResolutionException("There is no previous return gate to reference.");
            }
        }
Beispiel #6
0
        /// <summary>
        /// 处理向下的数据事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void Driver_OnNetDataCreated(object sender, NetDataEventCreatedArgs args)
        {
            string communicationCode = GatewayMapper.GetCommunicationCode(args.CommPort);

            GatewayManager.CommunicationManager.Send(communicationCode, args.DeviceCode, args.Data);
        }
Beispiel #7
0
 internal sealed override void WriteTargets()
 {
     GatewayMapper.WritePreviousGate(this.GetGuid());
     GatewayMapper.WriteTargetGate(_attachedGate);
 }