public void Bind(HostCore connection, IRemoteUnityDriver service, EndPointMap endPoints)
        {
            _connection = connection;
            _service    = service;


            BindClientCallbacks();
            BindHostMethodEndPoints(endPoints);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var endPointMap = new EndPointMap(new JsonSerializer());

            endPointMap.AddSendEndPoint <LogDTO>(Log);
            endPointMap.AddAskEndPoint <long, long>(Ping);

            var server = new HostCore(endPointMap);

            server.Start();

            Console.WriteLine("Server Started.");
            TestBroadcast(server);
        }
예제 #3
0
    public static void Bind <TService>(this HostCore host, TService serviceToBind) where TService : class
    {
        var serviceTypes = typeof(TService).Assembly.GetTypes();
        var serviceType  = serviceTypes
                           .First(t => {
            var bindingAttr = Attribute.GetCustomAttribute(t,
                                                           typeof(HostBindingAttribute));
            if (bindingAttr is HostBindingAttribute binding)
            {
                return(binding.ServiceType.IsAssignableFrom(typeof(TService)));
            }

            return(false);
        }
                                  );

        var bindMethod     = serviceType.GetMethod("Bind");
        var binderInstance = Activator.CreateInstance(serviceType);

        bindMethod?.Invoke(binderInstance, new object[] { host, serviceToBind, host.EndPoints });
    }
예제 #4
0
        private static void TestBroadcast(HostCore server)
        {
            int i = 0;

            while (true)
            {
                var log = new LogDTO {
                    //Message = "Short." };
                    Message = "This is some message " + (i++) + "! " +
                              "But it's really really long, because we need to " +
                              "test if the message can wrap it's buffer size " +
                              "and still be correctly reconstructed at the other " +
                              "end of the network. Because althought this protocol " +
                              "isn't optimised for large packets, we still want to " +
                              "be able to fully support them. Doing so makes this " +
                              "system much more flexible, and allows the sending of " +
                              "files, like images, video, binary updates, whatever " +
                              "you can imagine, it can send. I know that's a pretty " +
                              "standard feature, but the way other networking systems " +
                              "are built, they support this kind of thing at the expense " +
                              "of performance with smaller data packets. Not Tachyon, " +
                              "tachyon can send and recieve those tiny packets faster " +
                              "than the speed of light, and still handle the big ones."
                };
                if (i % 2 == 0)
                {
                    server.Broadcast("Log", log);
                }
                else
                {
                    server.Broadcast("LogWarning", new LogDTO {
                        Message = "."
                    });
                }

                Console.ReadKey();
            }
        }
 public ProcessRequestCommand(HostCore core) : base(core)
 {
 }
예제 #6
0
 public LogoutCommand(HostCore core) : base(core)
 {
 }
예제 #7
0
 protected CommandBase(HostCore core)
 {
     Core = core ?? throw new ArgumentNullException(nameof(core));
 }