public override void ExecuteCommand(UserClientEngine session, BaseCommandInfo commandInfo) { try { var newuser = SerializeHelp.Deserialize <User>(commandInfo.Data[0]); UserManage.Instance.AddUser(newuser); session.UserEvents.OnUserJoin(new UserJoinEventArgs(newuser)); } catch (Exception ex) { throw; } }
public override void ExecuteCommand(UpLoadClientEngine session, TransferCommandInfo commandInfo) { try { UpLoadInfo ServerConfigInfo = SerializeHelp.Deserialize <UpLoadInfo>(commandInfo.Data); long CurrentPos = ServerConfigInfo.TransferPos + ServerConfigInfo.TransferedLength; long TransferedLength = ServerConfigInfo.TransferedLength; long TransferLength = ServerConfigInfo.TransferLength; session.m_fileStream.Position = CurrentPos; session.UpLoadInfo = ServerConfigInfo; session.OnTransferStart(); while (TransferedLength < TransferLength) { lock (session.lockobj) { if (session == null) { return; } if (session.StatusCode == 1) { session.StatusCode = 2; session.m_StopEvent.Set(); return; } int length = session.m_fileStream.Read(session.readBuffer, 0, session.PacketSize); session.SendData(UpLoadOP.DoData, session.readBuffer, 0, length); TransferedLength += length; session.UpLoadInfo.TransferedLength = TransferedLength; session.OnTransferStep(TransferLength, TransferedLength, length); } } session.SendData(UpLoadOP.DoEnd, new byte[] { 1 }, 0, 1); new Action(() => { session.m_EndEvent.WaitOne(5000); session.DoEnd(); }).BeginInvoke(null, null); } catch (Exception ex) { //Log.Error(ex.ToString()); ex.ToString(); //error to do; } }
public override void ExecuteCommand(TransferSession session, BinaryRequestInfo requestInfo) { try { UpLoadInfo ClientConfigInfo = SerializeHelp.Deserialize <UpLoadInfo>(requestInfo.Body); string saveName = Path.GetFullPath(ClientConfigInfo.SaveName); if (File.Exists(saveName)) { File.Delete(saveName); } session.UpLoadEngine.OnStartTransfer(ClientConfigInfo); session.UpLoadEngine.DoUpLoad(ClientConfigInfo); } catch (System.Exception ex) { log4net.LogManager.GetLogger("DoCover").Error(ex.Message); } }