Beispiel #1
0
        /// <summary>
        /// Set up an implicit join between two tables.
        /// </summary>
        /// <param name="masterTableName">The name of the 'master' table</param>
        /// <param name="masterKey">The 'primary key'</param>
        /// <param name="masterPropertyName">The name to give the lookup property in the detail objects</param>
        /// <param name="detailTableName">The name of the 'master' table</param>
        /// <param name="detailKey">The 'foreign key'</param>
        /// <param name="detailPropertyName">The name to give the collection property in the master object</param>
        public void ConfigureJoin(string masterTableName, string masterKey, string masterPropertyName, string detailTableName, string detailKey, string detailPropertyName)
        {
            var join = new JoinInfo(masterTableName, masterKey, masterPropertyName, detailTableName, detailKey,
                                    detailPropertyName);

            _joins.Add(join);
        }
Beispiel #2
0
        public void ThreeTables()
        {
            var resolver = new JoinResolver();
            var result   = resolver.Resolve(
                new List <string> {
                "empires", "government_types", "planets"
            })
                           .ToList();

            Assert.Equal(2, result.Count);

            var first = new JoinInfo
            {
                ThisTable     = "empires",
                ThisColumn    = "government_type_id",
                ForeignTable  = "government_types",
                ForeignColumn = "id"
            };
            var second = new JoinInfo
            {
                ThisTable     = "empires",
                ThisColumn    = "id",
                ForeignTable  = "planets",
                ForeignColumn = "empire_id"
            };

            Assert.Equal(first, result[0]);
            Assert.Equal(second, result[1]);
        }
Beispiel #3
0
 public bool Equals(JoinInfo info)
 {
     return(ThisTable == info.ThisTable &&
            ThisColumn == info.ThisColumn &&
            ForeignTable == info.ForeignTable &&
            ForeignColumn == info.ForeignColumn);
 }
Beispiel #4
0
        private void ProcessMessage(byte[] buffer, int offset, int length)
        {
            var operationCode = MessageBase.GetOperationCode(buffer, offset);

            _logger.LogInfo($"Message received. Operation code: {operationCode}");
            if (operationCode != ShamanOperationCode.Bundle)
            {
                _receivedMessages.Add(new RawMessage
                {
                    Data          = buffer.ToArray(),
                    Offset        = offset,
                    Length        = length,
                    OperationCode = operationCode
                });
            }
            else
            {
                var bundleOperationCode = MessageBase.GetOperationCode(buffer, offset + 1);
                _logger.LogInfo($"It is bundle message ! {bundleOperationCode}");
                _receivedMessages.Add(new RawMessage
                {
                    Data          = buffer.ToArray(),
                    Offset        = offset + 1,
                    Length        = length - 1,
                    OperationCode = bundleOperationCode
                });
            }


            //save join info
            if (operationCode == ShamanOperationCode.JoinInfo)
            {
                _joinInfo = _serializer.DeserializeAs <JoinInfoEvent>(buffer, offset, length).JoinInfo;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Joins the call asynchronously.
        /// </summary>
        /// <param name="joinCallBody">The join call body.</param>
        /// <returns>The <see cref="ICall" /> that was requested to join.</returns>
        public async Task <ICall> JoinCallAsync(JoinCallBody joinCallBody)
        {
            // A tracking id for logging purposes. Helps identify this call in logs.
            var scenarioId = Guid.NewGuid();

            var(chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinURL);

            var tenantId     = (meetingInfo as OrganizerMeetingInfo).Organizer.GetPrimaryIdentity().GetTenantId();
            var mediaSession = this.CreateLocalMediaSession();

            var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, mediaSession)
            {
                TenantId = tenantId,
            };

            if (!string.IsNullOrWhiteSpace(joinCallBody.DisplayName))
            {
                // Teams client does not allow changing of ones own display name.
                // If display name is specified, we join as anonymous (guest) user
                // with the specified display name.  This will put bot into lobby
                // unless lobby bypass is disabled.
                joinParams.GuestIdentity = new Identity
                {
                    Id          = Guid.NewGuid().ToString(),
                    DisplayName = joinCallBody.DisplayName,
                };
            }

            var statefulCall = await this.Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false);

            statefulCall.GraphLogger.Info($"Call creation complete: {statefulCall.Id}");
            return(statefulCall);
        }
        /// <summary>
        /// Processa a junção.
        /// </summary>
        /// <param name="query">Informações da consulta.</param>
        /// <param name="join">Informações do join.</param>
        private LinkResult ProcessJoin(QueryInfo query, JoinInfo join)
        {
            LinkResult endResult = ProcessLinkResult(query, join.Conditional);

            ;
            return(endResult);
        }
Beispiel #7
0
        /// <summary>
        /// Joins the call asynchronously.
        /// </summary>
        /// <param name="joinCallBody">The join call body.</param>
        /// <param name="incidentId">Incident Id.</param>
        /// <returns>The <see cref="ICall"/> that was requested to join.</returns>
        public async Task <ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string incidentId = "")
        {
            // A tracking id for logging purposes. Helps identify this call in logs.
            var scenarioId = string.IsNullOrEmpty(joinCallBody.ScenarioId) ? Guid.NewGuid() : new Guid(joinCallBody.ScenarioId);

            Microsoft.Graph.MeetingInfo meetingInfo;
            ChatInfo chatInfo;

            (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinURL);

            var tenantId =
                joinCallBody.TenantId ??
                (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId();
            var mediaToPrefetch = new List <MediaInfo>();

            foreach (var m in this.MediaMap)
            {
                mediaToPrefetch.Add(m.Value.MediaInfo);
            }

            var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, new[] { Modality.Audio }, mediaToPrefetch)
            {
                TenantId = tenantId,
            };

            var statefulCall = await this.Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false);

            this.AddCallToHandlers(statefulCall, "BotMeeting");

            this.graphLogger.Info($"Join Call complete: {statefulCall.Id}");

            return(statefulCall);
        }
Beispiel #8
0
 public static bool IsSpectatorSlotAvailable(JoinInfo info)
 {
     if (info == null)
     {
         return(false);
     }
     if (!info.HasPartyId)
     {
         if (!info.HasServerIpAddress || !info.HasSecretKey)
         {
             return(false);
         }
         if (string.IsNullOrEmpty(info.SecretKey))
         {
             return(false);
         }
     }
     if (info.HasIsJoinable && !info.IsJoinable)
     {
         return(false);
     }
     if ((info.HasMaxNumSpectators && info.HasCurrentNumSpectators) && (info.CurrentNumSpectators >= info.MaxNumSpectators))
     {
         return(false);
     }
     return(true);
 }
 public JoinOrder(int index, string fromAlias, JoinInfo join)
 {
     this.Index     = index;
     this.FromAlias = fromAlias;
     this.ToAlias   = "_lf" + index;
     this.Join      = join;
 }
Beispiel #10
0
    public void JoinLobby()
    {
        Login     = PlayerPrefs.GetString("Name", "guest");
        parent_id = PlayerPrefs.GetInt("ID", 0);
        string lobbyNum = CleanForJSON(lobby.value);
        int    lob      = Int32.Parse(lobbyNum);

        PlayerPrefs.SetInt("Lobby", lob);

        // Create JoinInfo instance with username and hashed password
        JoinInfo info = new JoinInfo(lob, Login, parent_id, ready);

        // Create JSON out of info
        string jsonPayload = JsonConvert.SerializeObject(info);

        Debug.Log(jsonPayload);
        message.text = jsonPayload;

        string result;

        // Make HttpWebRequest to Login page
        HttpWebRequest request = WebRequest.Create("http://cop4331project.com/AddLobby.php") as HttpWebRequest;

        // Set type to JSON and method to post
        request.ContentType = "application/json";
        request.Method      = "POST";

        // Send JSON to php file
        using (var streamWriter = new StreamWriter(request.GetRequestStream()))
        {
            streamWriter.Write(jsonPayload);
            streamWriter.Flush();
            streamWriter.Close();
        }

        // Response variable holds response from JSON
        HttpWebResponse response = request.GetResponse() as HttpWebResponse;

        // Save string from JSON to result
        using (var streamReader = new StreamReader(response.GetResponseStream()))
        {
            result = streamReader.ReadToEnd();
        }

        // Convert JSON into instance of ReturnInfo type
        ReturnInfo ReturnInfo = JsonConvert.DeserializeObject <ReturnInfo>(result);

        message.text = ReturnInfo.error;

        PlayerPrefs.SetFloat("HLat", ReturnInfo.Lat_lon[0]);
        PlayerPrefs.SetFloat("HLong", ReturnInfo.Lat_lon[1]);
        PlayerPrefs.SetString("Time Limit", ReturnInfo.Lat_lon[2].ToString());

        GPS.latCenter = ReturnInfo.Lat_lon[0];
        GPS.lonCenter = ReturnInfo.Lat_lon[1];
        Debug.Log(ReturnInfo.Lat_lon[0] + " " + ReturnInfo.Lat_lon[1]);
        GPS.centerFound = true;
    }
        private void ProcessSuccess(MatchMakingPlayer player, JoinRoomResult result)
        {
            _logger.Debug($"Sending join info to {player.Id}");
            var joinInfo = new JoinInfo(result.Address, result.Port, result.RoomId, JoinStatus.RoomIsReady,
                                        GetCurrentPlayersWeight(), _totalPlayersNeeded, true);

            _messageSender.Send(new JoinInfoEvent(joinInfo), player.Peer);
            _playersManager.Remove(player.Id);
        }
        private void ProcessFailed(MatchMakingPlayer player, string message)
        {
            _logger.Error($"Sending matchmaking failed info to {player.Id}: {message}");
            _playersManager.SetOnMatchmaking(player.Id, false);
            var joinInfo = new JoinInfo("", 0, Guid.Empty, JoinStatus.MatchMakingFailed, 0, 0);

            _messageSender.Send(new JoinInfoEvent(joinInfo), player.Peer);
            _playersManager.Remove(player.Id);
        }
        /// <summary>
        /// Joins the call asynchronously.
        /// </summary>
        /// <param name="joinCallBody">The join call body.</param>
        /// <returns>The <see cref="ICall"/> that was requested to join.</returns>
        public async Task <ICall> JoinCallAsync(JoinCallController.JoinCallBody joinCallBody)
        {
            // A tracking id for logging purposes. Helps identify this call in logs.
            var correlationId = Guid.NewGuid();

            MeetingInfo meetingInfo;
            ChatInfo    chatInfo;

            if (!string.IsNullOrWhiteSpace(joinCallBody.MeetingId))
            {
                // Meeting id is a cloud-video-interop numeric meeting id.
                var onlineMeeting = await this.OnlineMeetings
                                    .GetOnlineMeetingAsync(joinCallBody.TenantId, joinCallBody.MeetingId, correlationId)
                                    .ConfigureAwait(false);

                meetingInfo = new OrganizerMeetingInfo {
                    Organizer = onlineMeeting.Participants.Organizer.Identity,
                };
                chatInfo = onlineMeeting.ChatInfo;
                //// meetingInfo.AllowConversationWithoutHost = joinCallBody.AllowConversationWithoutHost;
            }
            else
            {
                (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinURL);
            }

            var tenantId =
                joinCallBody.TenantId ??
                (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId();
            ILocalMediaSession mediaSession = this.CreateLocalMediaSession();

            var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, mediaSession)
            {
                RemoveFromDefaultAudioRoutingGroup = joinCallBody.RemoveFromDefaultRoutingGroup,
                TenantId      = tenantId,
                CorrelationId = correlationId,
            };

            if (!string.IsNullOrWhiteSpace(joinCallBody.DisplayName))
            {
                // Teams client does not allow changing of ones own display name.
                // If display name is specified, we join as anonymous (guest) user
                // with the specified display name.  This will put bot into lobby
                // unless lobby bypass is disabled.
                joinParams.GuestIdentity = new Identity
                {
                    Id          = Guid.NewGuid().ToString(),
                    DisplayName = joinCallBody.DisplayName,
                };
            }

            var statefulCall = await this.Client.Calls().AddAsync(joinParams).ConfigureAwait(false);

            this.logger.Info($"Call creation complete: {statefulCall.Id}");
            return(statefulCall);
        }
Beispiel #14
0
 public JoinConfig Master(string tableName, string keyName, string propertyNameInDetailRecords = null)
 {
     if (_joins.Contains(_joinInfo))
     {
         _joins.Remove(_joinInfo);
     }
     _joinInfo = new JoinInfo(tableName, keyName, propertyNameInDetailRecords ?? tableName, _joinInfo.DetailTableName,
                              _joinInfo.DetailKey, _joinInfo.DetailPropertyName);
     _joins.Add(_joinInfo);
     return(this);
 }
Beispiel #15
0
        /// <summary>
        /// Joins the call asynchronously.
        /// </summary>
        /// <param name="joinCallBody">The join call body.</param>
        /// <param name="incidentId">Incident Id.</param>
        /// <returns>The <see cref="ICall"/> that was requested to join.</returns>
        public async Task <ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string incidentId = "")
        {
            // A tracking id for logging purposes. Helps identify this call in logs.
            var correlationId = string.IsNullOrEmpty(joinCallBody.CorrelationId) ? Guid.NewGuid() : new Guid(joinCallBody.CorrelationId);

            Microsoft.Graph.MeetingInfo meetingInfo;
            ChatInfo chatInfo;

            if (!string.IsNullOrWhiteSpace(joinCallBody.MeetingId))
            {
                // Meeting id is a cloud-video-interop numeric meeting id.
                var onlineMeeting = await this.OnlineMeetings
                                    .GetOnlineMeetingAsync(joinCallBody.TenantId, joinCallBody.MeetingId, correlationId)
                                    .ConfigureAwait(false);

                meetingInfo = new OrganizerMeetingInfo {
                    Organizer = onlineMeeting.Participants.Organizer.Identity,
                };
                meetingInfo.AllowConversationWithoutHost = joinCallBody.AllowConversationWithoutHost;
                chatInfo = onlineMeeting.ChatInfo;
            }
            else
            {
                (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinURL);
                meetingInfo.AllowConversationWithoutHost = joinCallBody.AllowConversationWithoutHost;
            }

            var tenantId =
                joinCallBody.TenantId ??
                (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId();
            var mediaToPrefetch = new List <MediaInfo>();

            foreach (var m in this.MediaMap)
            {
                mediaToPrefetch.Add(m.Value.MediaInfo);
            }

            var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, new[] { Modality.Audio }, mediaToPrefetch)
            {
                RemoveFromDefaultAudioRoutingGroup = joinCallBody.RemoveFromDefaultRoutingGroup,
                TenantId      = tenantId,
                CorrelationId = correlationId,
            };

            var statefulCall = await this.Client.Calls().AddAsync(joinParams).ConfigureAwait(false);

            this.AddCallToHandlers(statefulCall, new IncidentCallContext(IncidentCallType.BotMeeting, incidentId));

            this.graphLogger.Info($"Join Call complete: {statefulCall.Id}");

            return(statefulCall);
        }
Beispiel #16
0
        /// <summary>
        /// Joins the call asynchronously.
        /// </summary>
        /// <param name="joinCallBody">The join call body.</param>
        /// <returns>The <see cref="ICall"/> that was requested to join.</returns>
        public async Task <ICall> JoinCallAsync(JoinCallController.JoinCallBody joinCallBody)
        {
            // A tracking id for logging purposes.  Helps identify this call in logs.
            var correlationId = Guid.NewGuid();

            MeetingInfo meetingInfo;
            ChatInfo    chatInfo;

            if (!string.IsNullOrWhiteSpace(joinCallBody.MeetingId))
            {
                var onlineMeeting = await this.OnlineMeetings
                                    .GetOnlineMeetingAsync(joinCallBody.TenantId, joinCallBody.MeetingId, correlationId)
                                    .ConfigureAwait(false);

                meetingInfo = onlineMeeting.MeetingInfo;
                chatInfo    = onlineMeeting.ChatInfo;
            }
            else
            {
                (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinURL);
            }

            var mediaSession = this.CreateLocalMediaSession(correlationId);

            var joinCallParameters = new JoinMeetingParameters(
                chatInfo,
                meetingInfo,
                mediaSession)
            {
                TenantId      = joinCallBody.TenantId,
                CorrelationId = correlationId,
            };

            if (!string.IsNullOrWhiteSpace(joinCallBody.DisplayName))
            {
                // Teams client does not allow changing of ones own display name.
                // If display name is specified, we join as anonymous (guest) user
                // with the specified display name.  This will put bot into lobby
                // unless lobby bypass is disabled.
                joinCallParameters.GuestIdentity = new Identity
                {
                    Id          = Guid.NewGuid().ToString(),
                    DisplayName = joinCallBody.DisplayName,
                };
            }

            var statefulCall = await this.Client.Calls().AddAsync(joinCallParameters).ConfigureAwait(false);

            statefulCall.GraphLogger.Info($"Call creation complete: {statefulCall.Id}");
            return(statefulCall);
        }
Beispiel #17
0
        public JoinRoomModule()
        {
            this.Post("/api/24", ctx =>
            {
                var args  = Serializer.Deserialize <JoinRoomArgs>(this.Request.Body);
                var token = this.Request.Headers["playertoken"].FirstOrDefault();
                var game  = GameManager.GetGameFromToken(token);

                if (string.IsNullOrEmpty(args.RoomId))
                {
                    args.RoomId = "$service-room$";
                }

                var room = game.Rooms.FirstOrDefault(r => r.Id == args.RoomId);

                string joinKey = null;

                switch (game.GameId)
                {
                default:
                    joinKey = JoinInfo.Create(
                        encryptionKey: GameManager.EncryptionKey,
                        serverId: "serverId",
                        gameId: 128,
                        gameConnectId: game.GameId,
                        gameCodeId: "gameCodeId",
                        serverType: room.RoomType,
                        roomId: args.RoomId,
                        roomData: new byte[] { },
                        extendedRoomId: game.GameId + "/" + room.RoomType + "/" + args.RoomId,
                        connectUserId: token.Split(':')[1],
                        playerIoToken: token,
                        visible: true,
                        roomFlags: 0,
                        partnerId: "",
                        userId: 1234,
                        gameCodeVersion: 1);
                    break;
                }

                return(PlayerIO.CreateResponse(token, true, new JoinRoomOutput()
                {
                    Endpoints = new List <ServerEndpoint>()
                    {
                        GameManager.GameServerEndPoint
                    },
                    JoinKey = joinKey
                }));
            });
        }
        private void SendJoinInfoToCurrentMatchmakingGroup()
        {
            lock (_queueSync)
            {
                foreach (var player in _matchmakingPlayers)
                {
                    _logger.Debug($"Sending prejoin info to {player.Id}");
                    var joinInfo = new JoinInfo("", 0, Guid.Empty, JoinStatus.OnMatchmaking, GetCurrentPlayersWeight(),
                                                _totalPlayersNeeded);

                    _messageSender.Send(new JoinInfoEvent(joinInfo), player.Peer);
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// Joins the call asynchronously.
        /// </summary>
        /// <param name="joinCallBody">The join call body.</param>
        /// <param name="incidentId">Incident Id.</param>
        /// <returns>The <see cref="ICall"/> that was requested to join.</returns>
        public async Task <ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string incidentId = "")
        {
            // A tracking id for logging purposes. Helps identify this call in logs.
            var scenarioId = string.IsNullOrEmpty(joinCallBody.ScenarioId) ? Guid.NewGuid() : new Guid(joinCallBody.ScenarioId);

            MeetingInfo meetingInfo;
            ChatInfo    chatInfo;

            if (!string.IsNullOrWhiteSpace(joinCallBody.VideoTeleconferenceId))
            {
                // Meeting id is a cloud-video-interop numeric meeting id.
                var onlineMeeting = await OnlineMeetings
                                    .GetOnlineMeetingAsync(joinCallBody.TenantId, joinCallBody.VideoTeleconferenceId, scenarioId)
                                    .ConfigureAwait(false);

                meetingInfo = new OrganizerMeetingInfo {
                    Organizer = onlineMeeting.Participants.Organizer.Identity,
                };
                chatInfo = onlineMeeting.ChatInfo;
            }
            else
            {
                (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinUrl);
            }

            var tenantId =
                joinCallBody.TenantId ??
                (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId();
            var mediaToPrefetch = new List <MediaInfo>();

            foreach (var m in MediaMap)
            {
                mediaToPrefetch.Add(m.Value.MediaInfo);
            }

            var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, new[] { Modality.Audio }, mediaToPrefetch)
            {
                TenantId = tenantId,
            };

            var statefulCall = await Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false);

            AddCallToHandlers(statefulCall, new IncidentCallContext(IncidentCallType.BotMeeting, incidentId));

            graphLogger.Info($"Join Call complete: {statefulCall.Id}");

            return(statefulCall);
        }
Beispiel #20
0
        /// <summary>
        /// 得到表名
        /// </summary>
        /// <param name="join"></param>
        /// <returns></returns>
        public virtual string GetGetTableName(JoinInfo join)
        {
            var getTableName = join.Map != null && join.Map.IsRemote && !string.IsNullOrEmpty(join.Map.RemoteName)
                ? join.Map.RemoteName
                : join.Object.GetTableName;

            if (join.Object.RouteName != Object.ObjectName && DbRoute != null && !DbRoute.IsMapTableAutoSharding)
            {
                return(getTableName);
            }
            if (!string.IsNullOrEmpty(TableIndex) && !string.IsNullOrEmpty(join.Object.RouteName))
            {
                return(string.Format("{0}{1}", getTableName, TableIndex));
            }
            return(getTableName);
        }
Beispiel #21
0
        /// <summary>
        /// 处理加入
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="data"></param>
        void ReplyJoin(string userID, byte[] data)
        {
            var channelID = Encoding.UTF8.GetString(data);

            _storage.SetUserChannelMapping(userID, channelID);

            _storage.SetChannelUserMapping(channelID, userID);

            var joinInfo = new JoinInfo()
            {
                ID        = userID,
                ChannelID = channelID
            };

            BaseReply(userID, ProtocalType.Join, Encoding.UTF8.GetBytes(SerializeHelper.Serialize(joinInfo)));
        }
Beispiel #22
0
        public Task <JoinInfo> DirectConnectToGameServer(string gameServerAddress, ushort gameServerPort, Guid sessionId, Guid roomId, Dictionary <byte, object> joinGameProperties)
        {
            _joinType           = JoinType.DirectJoin;
            _joinGameProperties = joinGameProperties;
            SessionId           = sessionId;

            var joinTask = new TaskCompletionSource <JoinInfo>();
            var cancellationTokenSource = new CancellationTokenSource(JoinGameTimeout);

            cancellationTokenSource.Token.Register(() => joinTask.TrySetCanceled());

            JoinInfo = new JoinInfo(gameServerAddress, gameServerPort, roomId, JoinStatus.RoomIsReady, 1, 1);

            _statusCallback = (status, info) =>
            {
                if (joinTask.Task.IsCompleted)
                {
                    return;
                }

                if (!status.IsSuccess || status.Status == ShamanClientStatus.Disconnected)
                {
                    joinTask.SetException(new ShamanClientException($"Client disconnected: {status.Error}"));
                    cancellationTokenSource.Dispose();
                }
                else if (info != null && info.Status == JoinStatus.MatchMakingFailed)
                {
                    joinTask.SetException(new ShamanClientException("Matchmaking failed"));
                    cancellationTokenSource.Dispose();
                }
                else if (status.Status == ShamanClientStatus.InRoom)
                {
                    joinTask.SetResult(info);
                    cancellationTokenSource.Dispose();
                }
            };

            SetAndReportStatus(ShamanClientStatus.ConnectingGameServer, _statusCallback);

            RegisterShamanOperationHandler <ConnectedEvent>(OnConnectedToGameServer, true);

            _clientPeer.Connect(gameServerAddress, gameServerPort);

            return(joinTask.Task);
        }
        //--------------------------------------------[Join Channels Background Worker]--------------------------------------------

        private void JoinChannelBW_DoWork(object sender, DoWorkEventArgs e)
        {
            try {
                JoinInfo Info = (JoinInfo)e.Argument;
                if (Info.NeedsPassword)
                {
                    joinResult = MainClient.Join(Info.Channel, Info.Password);
                }
                else
                {
                    joinResult = MainClient.Join(Info.Channel);
                }
            } catch (TimeoutException d) {
                joinResult = Colloquor.ColloquorClient.CQUORJoinResult.TIMEOUT;
            } catch (Exception d) {
                joinResult = Colloquor.ColloquorClient.CQUORJoinResult.UNKNOWN;
            }
        }
Beispiel #24
0
    public void StartGame()
    {
        starting = true;
        // set player join info
        foreach (SelectionInput input in inputs)
        {
            JoinInfo info = new JoinInfo();
            Debug.Log(input.characterIndex);
            info.characterType = input.characterIndex;
            info.team          = input.teamIndex;
            info.isAI          = !input.connected;

            PlayerManager.playerQueue.Add(info);
        }

        player.PlaySFX(highAudio);
        StartCoroutine(player.FadeOut(1.5f));
        StartCoroutine(LoadScene("Loading"));
        gameObject.GetComponent <Back>().Unbind();
        //SceneManager.LoadScene("Game");
    }
Beispiel #25
0
        public void TwoTables()
        {
            var resolver = new JoinResolver();
            var result   = resolver.Resolve(
                new List <string> {
                "empires", "government_types"
            })
                           .ToList();

            Assert.Single(result);

            var expected = new JoinInfo
            {
                ThisTable     = "empires",
                ThisColumn    = "government_type_id",
                ForeignTable  = "government_types",
                ForeignColumn = "id"
            };

            Assert.Equal(expected, result[0]);
        }
        private void ReplaceSignalName(string JoinToFind, List <JoinInfo> ListToSearch, string NewJoinName)
        {
            JoinInfo key   = new JoinInfo();
            int      index = -1;

            for (int i = 0; i < ListToSearch.Count; i++)
            {
                if (ListToSearch[i].currentJoin == JoinToFind)
                {
                    ListToSearch[i].currentJoin = NewJoinName;
                    ListToSearch[i].oldJoin     = JoinToFind;
                    break;
                }
            }

            //debugger_listBox.Items.Add("New Join Information is: " + key.newJoin,);
            //debugger_listBox.Items.Add("");

            SetJoinList(selectedSignalType);
            ClearNewJoinName();
            ClearCurrentJoinName();
        }
        private void JoinChannelButton_Click(object sender, EventArgs e)
        {
            JoinInfo Info;
            bool     Passworded = false;

            try { Passworded = Channels[ChannelsListbox.SelectedItem.ToString()]; }
            catch { MessageBox.Show("There's no channel selected!", "n o", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }



            if (Passworded)
            {
                Info = new JoinInfo(ChannelsListbox.SelectedItem.ToString(), PasswordBox.Text);
            }
            else
            {
                Info = new JoinInfo(ChannelsListbox.SelectedItem.ToString());
            }

            Enabled = false;
            JoinChannelBW.RunWorkerAsync(Info);
        }
        public void Test_TwoTables_JoinFound()
        {
            //4 tables
            var c1 = WhenIHaveA <ColumnInfo>();
            var c2 = WhenIHaveA <ColumnInfo>();

            //1 is primary
            c1.TableInfo.IsPrimaryExtractionTable = true;
            c1.TableInfo.SaveToDatabase();

            var j1 = new JoinInfo(Repository, c2, c1, ExtractionJoinType.Inner, null);

            QueryBuilder builder = new QueryBuilder(null, null);

            builder.AddColumn(new ColumnInfoToIColumn(Repository, c1));
            builder.AddColumn(new ColumnInfoToIColumn(Repository, c2));

            StringAssert.Contains("JOIN", builder.SQL);

            //we have 1 legit join go go team!
            Assert.AreEqual(1, builder.JoinsUsedInQuery.Count);
            Assert.AreEqual(j1, builder.JoinsUsedInQuery[0]);
        }
Beispiel #29
0
        private void JoinInfoReceived(JoinInfo joinInfo)
        {
            JoinInfo = joinInfo;
            _logger.Debug($"OnJoinInfoReceived: JoinInfo.Status {JoinInfo.Status}, JoinInfo.CurrentPlayers {JoinInfo.CurrentPlayers}, JoinInfo.MaxPlayers {JoinInfo.MaxPlayers}");

            SetAndReportStatus(_status, _statusCallback);

            //wait until we joined
            if (JoinInfo.Status == JoinStatus.RoomIsReady)
            {
                //start join room logic
                SetAndReportStatus(ClientStatusLegacy.JoiningRoom, _statusCallback);

                //disconnecting
                _clientPeer.Disconnect();

                //connect to game server
                _taskScheduler.ScheduleOnceOnNow(() =>
                {
                    UnregisterOperationHandler(_joinInfoEventId);
                    ConnectToGameServer(JoinInfo.ServerIpAddress, JoinInfo.ServerPort);
                });
            }
        }
Beispiel #30
0
 public JoinInfoMenu(RDMPContextMenuStripArgs args, JoinInfo j) : base(args, j)
 {
 }
Beispiel #31
0
        //!\\ TODO
        /// <summary>
        /// Merge given platforms with this one if they are tile-aligned with it.
        /// </summary>
        /// <param name="walls"></param>
        public void MergeWith(List<Wall> walls)
        {
            List<Wall> groundJoins = new List<Wall>() { this };
            List<Wall> wallJoins = new List<Wall>() { this };

            foreach (Wall wall in walls)
            {
                if ((Position.X - wall.Position.X) % GameData.TILE_SIZE != 0 ||
                    (Position.Y - wall.Position.Y) % GameData.TILE_SIZE != 0)
                {
                    // wall is not aligned, it is ignored
                    continue;
                }

                if (Summit == wall.Summit)
                    groundJoins.Add(wall);
                if (Bottom == wall.Bottom)
                    wallJoins.Add(wall);
            }

            FloatRect groundJoinsRect = GetGroundRect();
            FloatRect wallJoinsRect = GetWallRect();

            foreach (Wall wall in groundJoins)
            {
                FloatRect wallGroundJoinsRect = wall.GetGroundRect();

                groundJoinsRect = new FloatRect(
                    System.Math.Min(groundJoinsRect.Left, wallGroundJoinsRect.Left),
                    System.Math.Min(groundJoinsRect.Top, wallGroundJoinsRect.Top),
                    System.Math.Max(groundJoinsRect.Right, wallGroundJoinsRect.Right),
                    System.Math.Max(groundJoinsRect.Bottom, wallGroundJoinsRect.Bottom));
            }

            foreach (Wall wall in wallJoins)
            {
                FloatRect wallWallJoinsRect = wall.GetWallRect();

                wallJoinsRect = new FloatRect(
                    System.Math.Min(wallJoinsRect.Left, wallWallJoinsRect.Left),
                    System.Math.Min(wallJoinsRect.Top, wallWallJoinsRect.Top),
                    System.Math.Max(wallJoinsRect.Right, wallWallJoinsRect.Right),
                    System.Math.Max(wallJoinsRect.Bottom, wallWallJoinsRect.Bottom));
            }

            IntRect groundJoinsRectBase = new IntRect(
                0,
                0,
                (int)((groundJoinsRect.Right - groundJoinsRect.Left) / GameData.TILE_SIZE),
                (int)((groundJoinsRect.Bottom - groundJoinsRect.Top) / GameData.TILE_SIZE));

            IntRect wallJoinsRectBase = new IntRect(
                0,
                0,
                (int)((wallJoinsRect.Right - wallJoinsRect.Left) / GameData.TILE_SIZE),
                (int)((wallJoinsRect.Bottom - wallJoinsRect.Top) / GameData.TILE_SIZE));

            JoinInfo[,] groundJoinsTextures = new JoinInfo[groundJoinsRectBase.Rect.Height, groundJoinsRectBase.Rect.Width];
            IDrawable[,] wallJoinsTextures = new IDrawable[wallJoinsRectBase.Rect.Height, wallJoinsRectBase.Rect.Width];

            foreach (Wall wall in groundJoins)
            {
                for (int y = 0; y < wall.Height; ++y)
                {
                    for (int x = 0; x < wall.Width; ++x)
                    {
                        Vector2I offset = new Vector2I(
                            (int)((wall.GetGroundRect().Left - groundJoinsRect.Left) / GameData.TILE_SIZE),
                            (int)((wall.GetGroundRect().Top - groundJoinsRect.Top) / GameData.TILE_SIZE));
                        Vector2I index = new Vector2I(
                            x + offset.X,
                            y + offset.Y);
                        if (groundJoinsTextures[index.Y, index.X] != null)
                            continue;

                        JoinInfo joinInfo = new JoinInfo();
                        joinInfo.Wall = wall;
                        joinInfo.TextureCoordinates = new Vector2I(x, y);
                        groundJoinsTextures[index.Y, index.X] = joinInfo;
                    }
                }
            }

            for (int y = 0; y < groundJoinsRectBase.Rect.Height; ++y)
            {
                for (int x = 0; x < groundJoinsRectBase.Rect.Width; ++x)
                {
                    if (groundJoinsTextures[y, x] == null)
                        continue;

                    IntRect indexes = new IntRect(
                        x - 1,
                        y - 1,
                        x + 1,
                        y + 1);

                    bool
                        left = indexes.Left >= 0 && groundJoinsTextures[y, indexes.Left] != null,
                        top = indexes.Top >= 0 && groundJoinsTextures[indexes.Top, x] != null,
                        right = indexes.Right < groundJoinsRectBase.Right && groundJoinsTextures[y, indexes.Right] != null,
                        bottom = indexes.Bottom < groundJoinsRectBase.Bottom && groundJoinsTextures[indexes.Bottom, x] != null;

                    Log.Cl("Left[" + left + "], Top[" + top + "], Right[" + right + "], Bottom[" + bottom + "]");

                    JoinInfo joinInfo = groundJoinsTextures[y, x];
                    IDrawable tile = null;
                    //!\\ TODO + add 4 corners //!\\
                    if (left && top && right && bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.All);
                    else if (left && top && right)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.LeftTopRight);
                    else if (left && top && bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.TopLeftBottom);
                    else if (top && right && bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.TopRightBottom);
                    else if (left && right && bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.LeftBottomRight);
                    else if (left && right)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.LeftRight);
                    else if (left && top)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.TopLeft);
                    else if (left && bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.BottomLeft);
                    else if (top && right)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.TopRight);
                    else if (top && bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.TopBottom);
                    else if (right && bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.BottomRight);
                    else if (left)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.Left);
                    else if (right)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.Right);
                    else if (top)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.Top);
                    else if (bottom)
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.Bottom);
                    else
                        tile = AutoTile.GetJoinPattern(BlazeraLib.AutoTile.PartType.None);

                    joinInfo.Wall.RemoveTexture(joinInfo.Wall.GroundTextures[joinInfo.TextureCoordinates.Y, joinInfo.TextureCoordinates.X]);
                    //!\\ TODO
                    tile.Position = (new Vector2I(joinInfo.TextureCoordinates.X, joinInfo.TextureCoordinates.Y) * GameData.TILE_SIZE).ToVector2() + joinInfo.Wall.Position
                        - new SFML.Window.Vector2f(0F, joinInfo.Wall.Summit * GameData.TILE_SIZE);
                    joinInfo.Wall.AddTexture(tile, new Vector2I(joinInfo.TextureCoordinates.X, joinInfo.TextureCoordinates.Y));
                }
            }
        }