예제 #1
0
    private void OnMatchingUpdatedSession(Messages.PluginMessage msg)
    {
        Matching.GetSessionInformationPtr();
        OnScreenLog.Add("Session info updated...");
        Matching.Session session = Matching.GetSession();
        DumpSessionInfo(session);
        if (!InitializeHostAndSelf(session))
        {
            OnScreenLog.Add("ERROR: Expected members not found!");
        }
        if (Matching.IsHost)
        {
            return;
        }
        Matching.SessionMemberInfo?sessionMemberInfo = connected;
        if (sessionMemberInfo.HasValue)
        {
            return;
        }
        Matching.SessionMemberInfo value = host.Value;
        if (value.addr == 0)
        {
            OnScreenLog.Add("Unable to retrieve host IP address");
            ErrorHandler(Matching.LeaveSession());
            return;
        }
        Matching.SessionMemberInfo value2 = host.Value;
        string text = IntIPToIPString(value2.addr);

        object[] obj = new object[6]
        {
            "Connecting to ",
            text,
            ":",
            serverPort,
            " using signalling port:",
            null
        };
        Matching.SessionMemberInfo value3 = host.Value;
        obj[5] = value3.port;
        OnScreenLog.Add(string.Concat(obj));
        NetworkConnectionError networkConnectionError = Network.Connect(text, serverPort);

        if (networkConnectionError != 0)
        {
            OnScreenLog.Add("Connection failed: " + networkConnectionError);
            return;
        }
        OnScreenLog.Add("Connected to host " + text + " : " + serverPort);
        connected = host;
    }
    private void OnMatchingUpdatedSession(Messages.PluginMessage msg)
    {
        IntPtr sessionInformationPtr = Matching.GetSessionInformationPtr();

        OnScreenLog.Add("Session info updated...");
        Matching.Session session = Matching.GetSession();
        this.DumpSessionInfo(session);
        if (!this.InitializeHostAndSelf(session))
        {
            OnScreenLog.Add("ERROR: Expected members not found!");
        }
        if (!Matching.get_IsHost())
        {
            Matching.SessionMemberInfo?sessionMemberInfo = this.connected;
            if (!sessionMemberInfo.get_HasValue())
            {
                if (this.host.get_Value().addr == 0)
                {
                    OnScreenLog.Add("Unable to retrieve host IP address");
                    this.ErrorHandler(Matching.LeaveSession());
                    return;
                }
                string text = this.IntIPToIPString(this.host.get_Value().addr);
                OnScreenLog.Add(string.Concat(new object[]
                {
                    "Connecting to ",
                    text,
                    ":",
                    this.serverPort,
                    " using signalling port:",
                    this.host.get_Value().port
                }));
                NetworkConnectionError networkConnectionError = Network.Connect(text, this.serverPort);
                if (networkConnectionError != null)
                {
                    OnScreenLog.Add("Connection failed: " + networkConnectionError);
                }
                else
                {
                    OnScreenLog.Add(string.Concat(new object[]
                    {
                        "Connected to host ",
                        text,
                        " : ",
                        this.serverPort
                    }));
                    this.connected = this.host;
                }
            }
        }
    }