public int Receive(RailID user, byte[] buffer, int bufferOffset, int bufferSize) { uint num1 = 0; lock (this._pendingReadBuffers) { if (!this._pendingReadBuffers.ContainsKey(user)) { return(0); } Queue <WeGameP2PReader.ReadResult> pendingReadBuffer = this._pendingReadBuffers[user]; while (pendingReadBuffer.Count > 0) { WeGameP2PReader.ReadResult readResult = pendingReadBuffer.Peek(); uint num2 = Math.Min((uint)bufferSize - num1, readResult.Size - readResult.Offset); if (num2 == 0U) { return((int)num1); } Array.Copy((Array)readResult.Data, (long)readResult.Offset, (Array)buffer, (long)bufferOffset + (long)num1, (long)num2); if ((int)num2 == (int)readResult.Size - (int)readResult.Offset) { this._bufferPool.Enqueue(pendingReadBuffer.Dequeue().Data); } else { readResult.Offset += num2; } num1 += num2; } } return((int)num1); }
public void ContinueBackword(RailID id, CleanSteps step) { this.startTime = DateTime.Now; this.id = id; this.isPause = false; this.currentStep = (int)step; }
private void OnLobbyCreated(RailID lobbyID) { WeGameHelper.WriteDebugString("SetLocalPeer: {0}", (object)(ulong)((RailComparableID)lobbyID).id_); this._reader.SetLocalPeer(lobbyID); this._writer.SetLocalPeer(lobbyID); this._serverID = lobbyID; Action action = (Action)(() => { // ISSUE: explicit non-virtual call ReportServerID t = new ReportServerID() { _serverID = (((RailComparableID)lobbyID).id_.ToString()) }; IPCMessage msg = new IPCMessage(); msg.Build <ReportServerID>(IPCMessageType.IPCMessageTypeReportServerID, t); WeGameHelper.WriteDebugString("Send serverID to game client - " + this._client.SendMessage(msg).ToString()); }); if (this._serverConnected) { action(); } else { this._ipcConnetedAction += action; WeGameHelper.WriteDebugString("report server id fail, no connection"); } }
private void AsyncGetServerIDByOwener(RailID ownerID) { rail_api.RailFactory().RailFriends()?.AsyncGetFriendMetadata(ownerID, new List <string>() { this._serverIDMedataKey }, ""); }
private void stopBtn_Click(object sender, EventArgs e) { if (!this.railsControler.IsAllStoped) { DialogResult result = MessageBox.Show("确实终止清理", "确认", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { RailID id = this.railsControler.WorkingNum; bool isSuccess = MachinePortal.StopAutoClean(id); if (!isSuccess) { MessageBox.Show("终止清理失败!"); } else { this.railsControler.Stop(); this.CurrentCleanStep = CleanSteps.UnSupported; this.saveSpendTimeDic.Clear(); this.updateUiThread.Abort(); this.timerThread1.Abort(); this.timerThread2.Abort(); this.timerThread3.Abort(); this.startBtn.BackgroundImage = global::CleanSys.Properties.Resources.NewStartBtn; this.InitProcessBar(); this.RenewTimer(true); this.CurrentStatus = "ready"; this.GunDongFont.Text = this.GetGunDongText(id, this.CurrentStatus); } } } else { MessageBox.Show("清理没有进行,无需终止!"); } }
public void QueueSend(RailID user, byte[] data, int length) { lock (this._lock) { Queue <WeGameP2PWriter.WriteInformation> writeInformationQueue; if (this._pendingSendData.ContainsKey(user)) { writeInformationQueue = this._pendingSendData[user]; } else { this._pendingSendData[user] = writeInformationQueue = new Queue <WeGameP2PWriter.WriteInformation>(); } int val1 = length; int sourceIndex = 0; while (val1 > 0) { WeGameP2PWriter.WriteInformation writeInformation; if (writeInformationQueue.Count == 0 || 1024 - writeInformationQueue.Peek().Size == 0) { writeInformation = this._bufferPool.Count <= 0 ? new WeGameP2PWriter.WriteInformation() : new WeGameP2PWriter.WriteInformation(this._bufferPool.Dequeue()); writeInformationQueue.Enqueue(writeInformation); } else { writeInformation = writeInformationQueue.Peek(); } int length1 = Math.Min(val1, 1024 - writeInformation.Size); Array.Copy((Array)data, sourceIndex, (Array)writeInformation.Data, writeInformation.Size, length1); writeInformation.Size += length1; val1 -= length1; sourceIndex += length1; } } }
public override bool Send(RemoteAddress address, byte[] data, int length) { RailID user = RemoteAddressToRailId(address); _writer.QueueSend(user, data, length); return(true); }
/// <summary> /// 开始 暂停 单击响应方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StartPause_Click(object sender, EventArgs e) { RailID selectedID = RailID.UnSupported; AutoCleanStatus currentStatus = this.railsControler.CurrnetStatus; switch (currentStatus) { case AutoCleanStatus.Ready: selectedID = this.railsControler.SelectedRailNum; this.StartClean(selectedID); break; case AutoCleanStatus.Running: selectedID = this.railsControler.RunningNum; this.PauseClean(selectedID); break; case AutoCleanStatus.Pause: selectedID = this.railsControler.PauseNum; this.ContinueClean(selectedID); break; default: MessageBox.Show("请先选择要清理的轨道!"); break; } }
public void QueueSend(RailID user, byte[] data, int length) { lock (_lock) { Queue <WriteInformation> queue2 = _pendingSendData.ContainsKey(user) ? _pendingSendData[user] : (_pendingSendData[user] = new Queue <WriteInformation>()); int num = length; int num2 = 0; while (num > 0) { WriteInformation writeInformation; if (queue2.Count == 0 || 1024 - queue2.Peek().Size == 0) { writeInformation = ((_bufferPool.Count <= 0) ? new WriteInformation() : new WriteInformation(_bufferPool.Dequeue())); queue2.Enqueue(writeInformation); } else { writeInformation = queue2.Peek(); } int num3 = Math.Min(num, 1024 - writeInformation.Size); Array.Copy(data, num2, writeInformation.Data, writeInformation.Size, num3); writeInformation.Size += num3; num -= num3; num2 += num3; } } }
public override void Close(RemoteAddress address) { CleanMyMetaData(); RailID remote_peer = RemoteAddressToRailId(address); Close(remote_peer); }
private void OnGetFriendMetaData(RailFriendsGetMetadataResult data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if ((int)((EventBase)data).result != 0 || data.friend_kvs.Count <= 0) { return; } WeGameHelper.WriteDebugString("OnGetFriendMetaData - " + DumpMataDataString(data.friend_kvs)); string valueByKey = GetValueByKey(_serverIDMedataKey, data.friend_kvs); if (valueByKey == null) { return; } if (valueByKey.Length > 0) { RailID val = (RailID)(object)new RailID(); ((RailComparableID)val).id_ = ulong.Parse(valueByKey); if (((RailComparableID)val).IsValid()) { JoinServer(val); } else { WeGameHelper.WriteDebugString("JoinServer failed, invalid server id"); } } else { WeGameHelper.WriteDebugString("can not find server id key"); } }
public static bool SendCMD(RailID railID, CleanCommand cmd, CleanSteps step) { switch (cmd) { case CleanCommand.Forward: mockReceiver.Forward(railID, step); break; case CleanCommand.ContinueForward: mockReceiver.ContinueForward(railID, step); break; case CleanCommand.Backward: mockReceiver.Backward(railID, step); break; case CleanCommand.ContinueBackword: mockReceiver.ContinueBackword(railID, step); break; case CleanCommand.PauseManualClean: mockReceiver.PauseManualClean(railID); break; case CleanCommand.StopManualClean: mockReceiver.StopManualClean(railID); break; } return(true); }
private void CheckParameters() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown RailID server_id = (RailID)(object)new RailID(); if (GetRailConnectIDFromCmdLine(server_id)) { if (((RailComparableID)server_id).IsValid()) { Main.OpenPlayerSelect(delegate(PlayerFileData playerData) { Main.ServerSideCharacter = false; playerData.SetAsActive(); Main.menuMode = 882; Main.statusText = Language.GetTextValue("Social.Joining"); WeGameHelper.WriteDebugString(" CheckParameters, lobby.join"); JoinServer(server_id); }); } else { WeGameHelper.WriteDebugString("Invalid RailID passed to +connect_lobby"); } } }
/// <summary> /// img click 事件接受器 /// </summary> /// <param name="sender">事件发起方</param> /// <param name="e">参数</param> private void img_Click(object sender, EventArgs e) { SkinPictureBox img = sender as SkinPictureBox; RailID id = this.ConvertNameToID(img.Name); RailMode rail = this.RailDic[id]; if (this.IsAllStoped) { switch (rail.Progress) { // 如果 其他轨道 被选中,并且所有 轨道 都没有在工作, 则特定 轨道 被选中,其他都清除状态 // 如果所有的 轨道 都没有被选中,则直接选中 case RailProgress.UnSelected: case RailProgress.Stop: this.ClearOtherRail(id); rail.Progress = RailProgress.Selected; break; // 再次单击已选中轨道,取消选中 case RailProgress.Selected: rail.Progress = RailProgress.UnSelected; break; // 单击已经清理过的轨道, 弹窗提示 case RailProgress.Done: DialogResult result = MessageBox.Show("该轨道已经清理过,是否确认重新清理?", "确认对话框", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { rail.Progress = RailProgress.Selected; } break; } } }
private void OnLobbyCreated(RailID lobbyID) { WeGameHelper.WriteDebugString("SetLocalPeer: {0}", ((RailComparableID)lobbyID).id_); _reader.SetLocalPeer(lobbyID); _writer.SetLocalPeer(lobbyID); _serverID = lobbyID; Action action = delegate { ReportServerID t = new ReportServerID { _serverID = ((RailComparableID)lobbyID).id_.ToString() }; IPCMessage iPCMessage = new IPCMessage(); iPCMessage.Build(IPCMessageType.IPCMessageTypeReportServerID, t); WeGameHelper.WriteDebugString("Send serverID to game client - " + _client.SendMessage(iPCMessage)); }; if (_serverConnected) { action(); return; } _ipcConnetedAction = (Action)Delegate.Combine(_ipcConnetedAction, action); WeGameHelper.WriteDebugString("report server id fail, no connection"); }
/// <summary> /// 开始 清理 /// </summary> /// <param name="selectedID"></param> private void StartClean(RailID selectedID) { bool isSuccess = MachinePortal.StartAutoClean(selectedID); if (isSuccess) { // 更新开始按钮图片 this.startBtn.BackgroundImage = global::CleanSys.Properties.Resources.NewPauseBtn; //更新八角形UI:轨道颜色 this.railsControler.Start(); // 启动界面更新线程,更新进度百分比,更新模拟小车, this.CleanDistance = 0; this.InitProcessBar(); // 重置三个计时器 this.RenewTimer(true); this.timerThread1.Start(new TimeSpan(0, 0, 0)); // 重置更新UI 线程 this.updateUiThread = new Thread(this.getter.GetStatus); this.updateUiThread.IsBackground = true; this.updateUiThread.Start(); this.CurrentCleanStep = CleanSteps.CleanRail; this.CurrentStatus = "running"; this.GunDongFont.Text = this.GetGunDongText(selectedID, this.CurrentStatus); } else { MessageBox.Show("发送“清理”请求失败,检查网络情况!"); } }
private void stopBtn_Click(object sender, EventArgs e) { if (!this.railsControler.IsAllStoped) { DialogResult result = MessageBox.Show("确实终止清理", "确认", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { RailID id = this.railsControler.WorkingNum; bool isSuccess = MachinePortal.StopManualClean(id); if (!isSuccess) { MessageBox.Show("终止清理失败!"); } else { this.railsControler.Stop(); this.cleanStep = CleanSteps.UnSupported; this.UpdateUpArrowLocation(0); this.ClearStepBtns(); this.PauseManual(); } } } else { MessageBox.Show("清理没有进行,无需终止!"); } }
private void OnGetFriendMetaData(RailFriendsGetMetadataResult data) { if (((EventBase)data).result != null || ((List <RailKeyValueResult>)data.friend_kvs).Count <= 0) { return; } WeGameHelper.WriteDebugString("OnGetFriendMetaData - " + this.DumpMataDataString((List <RailKeyValueResult>)data.friend_kvs)); string valueByKey = this.GetValueByKey(this._serverIDMedataKey, (List <RailKeyValueResult>)data.friend_kvs); if (valueByKey == null) { return; } if (valueByKey.Length > 0) { RailID server_id = new RailID(); ((RailComparableID)server_id).id_ = (__Null)(long)ulong.Parse(valueByKey); if (((RailComparableID)server_id).IsValid()) { this.JoinServer(server_id); } else { WeGameHelper.WriteDebugString("JoinServer failed, invalid server id"); } } else { WeGameHelper.WriteDebugString("can not find server id key"); } }
private void CheckParameters() { RailID server_id = new RailID(); if (!this.GetRailConnectIDFromCmdLine(server_id)) { return; } if (((RailComparableID)server_id).IsValid()) { Main.OpenPlayerSelect((Main.OnPlayerSelected)(playerData => { Main.ServerSideCharacter = false; playerData.SetAsActive(); Main.menuMode = 882; Main.statusText = Language.GetTextValue("Social.Joining"); WeGameHelper.WriteDebugString(" CheckParameters, lobby.join"); this.JoinServer(server_id); })); } else { WeGameHelper.WriteDebugString("Invalid RailID passed to +connect_lobby"); } }
public void ClearUser(RailID id) { lock (_pendingReadBuffers) { _deletionQueue.Enqueue(id); } }
public int Receive(RailID user, byte[] buffer, int bufferOffset, int bufferSize) { uint num = 0u; lock (_pendingReadBuffers) { if (!_pendingReadBuffers.ContainsKey(user)) { return(0); } Queue <ReadResult> queue = _pendingReadBuffers[user]; while (queue.Count > 0) { ReadResult readResult = queue.Peek(); uint num2 = Math.Min((uint)(bufferSize - (int)num), readResult.Size - readResult.Offset); if (num2 == 0) { return((int)num); } Array.Copy(readResult.Data, readResult.Offset, buffer, bufferOffset + num, num2); if (num2 == readResult.Size - readResult.Offset) { _bufferPool.Enqueue(queue.Dequeue().Data); } else { readResult.Offset += num2; } num += num2; } return((int)num); } }
public void SetLocalPeer(RailID rail_id) { if (RailComparableID.op_Equality((RailComparableID)this._local_id, (RailComparableID)null)) { this._local_id = new RailID(); } ((RailComparableID)this._local_id).id_ = ((RailComparableID)rail_id).id_; }
public void SetLocalPeer(RailID rail_id) { if ((RailComparableID)this._local_id == (RailComparableID)null) { this._local_id = new RailID(); } ((RailComparableID)this._local_id).id_ = ((RailComparableID)rail_id).id_; }
public void SetLocalPeer(RailID rail_id) { if (this._local_id == null) { this._local_id = new RailID(); } this._local_id.id_ = rail_id.id_; }
private bool IsActiveUser(RailID user) { if (_connectionStateMap.ContainsKey(user)) { return(_connectionStateMap[user] != ConnectionState.Inactive); } return(false); }
protected bool GetSessionState(RailID userId, RailNetworkSessionState state) { if (rail_api.RailFactory().RailNetworkHelper().GetSessionState(userId, state) == null) { return(true); } WeGameHelper.WriteDebugString("GetSessionState Failed user:{0}", (object)(ulong)((RailComparableID)userId).id_); return(false); }
private void TerminateRemotePlayerSession(RailID remote_id) { IRailPlayer val = rail_api.RailFactory().RailPlayer(); if (val != null) { val.TerminateSessionOfPlayer(remote_id); } }
public override bool IsConnected(RemoteAddress address) { if (address == null) { return(false); } RailID railId = this.RemoteAddressToRailId(address); return(this._connectionStateMap.ContainsKey(railId) && this._connectionStateMap[railId] == NetSocialModule.ConnectionState.Connected); }
private void OnGameServerCreated(CreateGameServerResult result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)((EventBase)result).result == 0) { _gameServerInitSuccess = true; _lobbyCreatedExternalCallback(result.game_server_id); _server_id = result.game_server_id; } }
public override int Receive(RemoteAddress address, byte[] data, int offset, int length) { if (address == null) { return(0); } RailID user = RemoteAddressToRailId(address); return(_reader.Receive(user, data, offset, length)); }