Exemplo n.º 1
0
        public static PeerToPeerClient CreateConnected(string url, int port, Action <PeerToPeerClient> onConnectionSuccess, Action onConnectionFailed)
        {
            var client = new PeerToPeerClient();

            client.OnConnectionSuccess = () => onConnectionSuccess(client);
            client.OnConnectionFail    = onConnectionFailed;
            client.Init(url, port);
            return(client);
        }
Exemplo n.º 2
0
        public static Messenger CreateClient(string url, int port, Action <Messenger, PeerToPeerClient> onConnectionSuccess, Action <Messenger> onConnectionFailed)
        {
            var messenger = new Messenger();
            var client    = PeerToPeerClient.CreateConnected(url, port, (c) => onConnectionSuccess(messenger, c), () => onConnectionFailed(messenger));

            messenger._networker    = client;
            client.ReceivedCallback = messenger.ReceivedMessage;
            return(messenger);
        }