TryInit() public static method

public static TryInit ( ) : bool
return bool
コード例 #1
0
        public static Communicator Create()
        {
            ChannelEventDispatcher.TryInit();

            var communicator = new Communicator();

            communicator.ChannelFactory.TaskFactory = new UnitySlimTaskFactory {
                Owner = ChannelEventDispatcher.Instance
            };
            ((ObserverRegistry)communicator.ObserverRegistry).EventPoster = c => ChannelEventDispatcher.Post(c, null);

            return(communicator);
        }
コード例 #2
0
        public static ChannelFactory Build(IPacketSerializer packetSerializer = null, IPEndPoint endPoint = null, Func <ILog> createChannelLogger = null)
        {
            ChannelEventDispatcher.TryInit();

            if (packetSerializer == null)
            {
                packetSerializer = PacketSerializer.CreatePacketSerializer();
            }

            var channelFactory = new ChannelFactory
            {
                Type                = ChannelType.Tcp,
                ConnectEndPoint     = endPoint,
                CreateChannelLogger = createChannelLogger,
                TaskFactory         = new UnitySlimTaskFactory {
                    Owner = ChannelEventDispatcher.Instance
                },
                ObserverEventPoster = c => ChannelEventDispatcher.Post(c, null),
                PacketSerializer    = packetSerializer
            };

            return(channelFactory);
        }