public void TestClientInfo()
        {
            string clientid = "015186";

            ClientData data = new ClientData();
            ClientEntity result = data.GetClientInfo(clientid);

            Assert.IsNotNull(result, "No client data has been returned for {0}", clientid);
            Assert.AreEqual("Winston House, 349 Regents Park Road, Finchley, London", result.Address.Trim(), "Invalid value returned for Address");
            Assert.AreEqual("Alan Mays", result.Contact.Trim(), "Invalid value returned for Contact");
            Assert.AreEqual("OSMOND GAUT & ROSE", result.Name.Trim(), "Invalid value returned for Name");
            Assert.AreEqual("N3 1DH", result.Postcode.Trim(), "Invalid value returned for Postcode");
            Assert.AreEqual("015186", result.Refno.Trim(), "Invalid value returned for Refno");

            clientid = "1907";

            data = new ClientData();
            result = data.GetClientInfo(clientid);

            Assert.IsNotNull(result, "No client data has been returned for {0}", clientid);
            Assert.AreEqual("15 DRINKWATER STREET,DOUGLAS,ISLE OF MAN", result.Address.Trim(), "Invalid value returned for Address");
            Assert.AreEqual("M.B.MAJID", result.Contact.Trim(), "Invalid value returned for Contact");
            Assert.AreEqual("REGAL ESTATES LTD", result.Name.Trim(), "Invalid value returned for Name");
            Assert.AreEqual("IM1 1AT", result.Postcode.Trim(), "Invalid value returned for Postcode");
            Assert.AreEqual("1907", result.Refno.Trim(), "Invalid value returned for Refno");
        }
Beispiel #2
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            Initer.Init(@"Server=ADWA;Database=Hotel;Trusted_Connection=true");

            var clientData = new ClientData("test", "test", "test", "test");
            var client = new Client { ClientData = clientData };
            var repo = new ClientRepository();
            repo.Save(client);

            var features = new List<Feature>();
            features.Add(Feature.Bathroom);
            var room = new Room { Quality = RoomQuality.Average, Features = features, Type = RoomType.HotelRoom };
            room.SetCapacity(5);

            var roomRepo = new RoomRepository();
            roomRepo.Save(room);

            var features2 = new List<Feature>();
            features2.Add(Feature.Bathroom);
            features2.Add(Feature.Tv);
            var room2 = new Room { Quality = RoomQuality.Good, Features = features2, Type = RoomType.HotelRoom };
            room2.SetCapacity(2);

            roomRepo.Save(room2);

            var duration = new DayDuration(DateTime.Now, DateTime.Now.AddDays(1));
            var reservation = new Reservation(client, room, duration);
            var reservationRepo = new ReservationRepository();
            reservationRepo.Save(reservation);
        }
	public ClientData GetClientData(int playerId) {
		ClientData client = new ClientData(-1);
		if (!clients.TryGetValue (playerId, out client)) {
			Debug.LogError ("Can not find a ClientData for playerId: " + playerId);
		}
		return client;
	}
	public override void RcvConnect(int rcvHostId, int connectionId, int channelId) {
		playersConnected++;
		textField.text = playersConnected + "";

		ClientData client = new ClientData (connectionId);
		networkManager.AddClientData (client);
		CheckReady ();
		//TODO this is kind of an ugly hack to auto-ready;
	}
        public int RegisterMailbox(MessageEvaluator evaluator)
        {
            var id = _nextId++;
            _clients[id] = new ClientData
            {
                Messages = new List<IIncomingEmailMessage>(),
                Evaluator = evaluator
            };

            return id;
        }
		public void Connect()
		{
			if (!tsClient.IsConnected)
			{
				tsClient.Connect(connectionData.host, connectionData.port);
				tsClient.Login(connectionData.user, connectionData.passwd);
				tsClient.UseServer(1);
				try { tsClient.ChangeName("TS3AudioBot"); }
				catch (QueryCommandException) { Log.Write(Log.Level.Warning, "TS3AudioBot name already in use!"); }

				me = GetSelf();

				tsClient.RegisterNotification(MessageTarget.Server, -1);
				tsClient.RegisterNotification(MessageTarget.Private, -1);
				tsClient.RegisterNotification(RequestTarget.Server, -1);

				TickPool.RegisterTick(() => tsClient.WhoAmI(), PingInterval, true);
			}
		}
Beispiel #7
0
        /// <summary>
        /// конструктор
        /// </summary>
        /// <param name="Original">оригинальный тест</param>
        /// <param name="client">интернет соединение</param>
        public Client(byte[] bytes,ref Test Original)
        {
            this.Buffer = bytes;
            this.OrigialTest = Original;
            this.Data = new ClientData();

            if (SetIdentificationData(this.Buffer) == false)
            {
                throw new Exception();
            }

            try
            {
                string FileString = UTF8Encoding.GetString(bytes);
                FileString = Regex.Replace(FileString, "\\0", "");
                FileString = Regex.Replace(FileString, "#@[email protected]#", "");
                this.CurrentXml = XDocument.Parse(FileString);
            }
            catch
            {
                throw new Exception();
            }
        }
Beispiel #8
0
        public void SendResponse(ClientData clientData, NetworkStream stream)
        {
            ServerData serverData = new ServerData
            {
                Id = clientData.Id
            };

            try
            {
                serverData.Text = Helper.ProcessClientData(clientData);
                serverData.Status = "Success";
            }
            catch (Exception ex)
            {
                serverData.Text = ex.Message;
                serverData.Status = "Error";
            }

            byte[] buffer = Helper.SdoSerializeServerData(serverData);

            stream.Write(buffer, 0, buffer.Length);
            stream.Flush();
        }
Beispiel #9
0
        private void CreateTabPage(ClientData item)
        {
            if (InvokeRequired)
            {
                Invoke(
                    new CreateTabPageDelegate(CreateTabPage),
                    item);
            }
            else
            {
                TabPage tp = new TabPage(item.ClientName);
                tp.Tag = item;

                UCChatControl uc = new UCChatControl();

                tp.Controls.Add(uc);
                uc.Location = new Point(0, 0);
                uc.Dock = DockStyle.Fill;
                uc.CData = item;
                _ucChatControls.Add(item.ClientID, uc);

                tabControl1.TabPages.Add(tp);
            }
        }
        protected override void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId, uint timestamp)
        {       
            base.ServerRead(stream, clientId, timestamp);
            bool clientHasCharacter = stream.ReadBool();
            if (clientHasCharacter)
            {
                MyEntity support;
                bool hasSupport = stream.ReadBool();
                Vector3D supportPosition = Vector3D.Zero;

                if (m_character != null)
                {
                    var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup<MyCharacterPhysicsStateGroup>();
                    if (physGroup != null)
                    {
                        m_support = MySupportHelper.FindSupportForCharacterAABB(m_character);
                        physGroup.SetSupport(MySupportHelper.FindPhysics(m_support));
                    }
                }

                 if (hasSupport)
                 {
                     long supportId = stream.ReadInt64();
                     bool apply = MyEntities.TryGetEntityById(supportId, out support);
                     supportPosition = stream.ReadVector3D();
                 }


                if(m_additionalServerClientData == null)
                {
                    m_additionalServerClientData = new Dictionary<ulong, ClientData>();
                }

                m_additionalServerClientData[clientId] = new ClientData() { HasSupport = hasSupport, SupportPosition = supportPosition };

                Vector3 move = new Vector3();
                move.X = stream.ReadHalf();
                move.Y = stream.ReadHalf();
                move.Z = stream.ReadHalf();

                Vector2 rotate = new Vector2();
                rotate.X = stream.ReadFloat();
                rotate.Y = stream.ReadFloat();

                float roll = stream.ReadFloat();

                MyCharacterMovementEnum MovementState = (MyCharacterMovementEnum)stream.ReadUInt16();
                MyCharacterMovementFlags MovementFlag = (MyCharacterMovementFlags)stream.ReadUInt16();

                bool Jetpack = stream.ReadBool();
                bool Dampeners = stream.ReadBool();
                bool Lights = stream.ReadBool(); // TODO: Remove
                bool Ironsight = stream.ReadBool();
                bool Broadcast = stream.ReadBool(); // TODO: Remove
                bool TargetFromCamera = stream.ReadBool();
                float headXAngle = stream.ReadFloat();
                float headYAngle = stream.ReadFloat();

                if(m_character == null)
                {
                    return;
                }

                if (m_character.IsUsing != null)
                {
                    return;
                }

                var jetpack = m_character.JetpackComp;
                if (jetpack != null)
                {
                    if (Jetpack != jetpack.TurnedOn)
                    {
                        jetpack.TurnOnJetpack(Jetpack, true);
                    }
                    if (Dampeners != jetpack.DampenersTurnedOn)
                    {
                        jetpack.EnableDampeners(Dampeners, false);
                    }
                }

                if (Lights != m_character.LightEnabled)
                {
                    m_character.EnableLights(Lights);
                }

                if (m_character.RadioBroadcaster != null && Broadcast != m_character.RadioBroadcaster.Enabled)
                {
                    m_character.EnableBroadcasting(Broadcast);
                }

                m_character.TargetFromCamera = TargetFromCamera;

                // Set client movement state directly and don't perform other operations
                // that may have side-effects to let server side Character.UpdateAfterSimulation()
                // perform exactly same operations as on client
                m_character.MovementFlags = MovementFlag;
                if (m_character.IsDead == false)
                {
                    m_character.SetCurrentMovementState(MovementState);
                }
                m_character.HeadLocalXAngle = headXAngle;
                m_character.HeadLocalYAngle = headYAngle;
                if (m_commandsApplied == null)
                {
                    m_commandsApplied = new Dictionary<ulong, bool>();
                }

                if (Vector3.IsZero(move, 0.01f) == false || Vector2.IsZero(ref rotate, 0.01f) == false || Math.Abs(roll - 0.0) > 0.01f)
                {            
                    m_commandsApplied[clientId] = true;
                }

                m_character.CacheMove(ref move, ref rotate, ref roll);
            }    
        }
 void DispatchEvent(ClientData client, float priority, EndpointId endpointId, BitStream stream, bool reliable)
 {
     if (reliable)
     {
         m_callback.SendEvent(stream, true, endpointId);
     }
     else
     {
         client.EventQueue.Enqueue(stream, priority, endpointId);
     }
 }
Beispiel #12
0
static void testvfs_obj_del(ClientData cd){
  Testvfs p = (Testvfs)cd;
  if ( p.pScript !=null)
    TCL.Tcl_DecrRefCount( ref p.pScript );
  sqlite3_vfs_unregister(p.pVfs);
  Debugger.Break();//TODO
  //ckfree((char )p.pVfs);
  //ckfree((char )p);
}
Beispiel #13
0
/*
** Usage:  testvfs VFSNAME ?SWITCHES?
**
** Switches are:
**
**   -noshm   BOOLEAN             (True to omit shm methods. Default false)
**   -default BOOLEAN             (True to make the vfs default. Default false)
**
** This command creates two things when it is invoked: an SQLite VFS, and
** a Tcl command. Both are named VFSNAME. The VFS is installed. It is not
** installed as the default VFS.
**
** The VFS passes all file I/O calls through to the underlying VFS.
**
** Whenever the xShmMap method of the VFS
** is invoked, the SCRIPT is executed as follows:
**
**   SCRIPT xShmMap    FILENAME ID
**
** The value returned by the invocation of SCRIPT above is interpreted as
** an SQLite error code and returned to SQLite. Either a symbolic 
** "SQLITE_OK" or numeric "0" value may be returned.
**
** The contents of the shared-memory buffer associated with a given file
** may be read and set using the following command:
**
**   VFSNAME shm FILENAME ?NEWVALUE?
**
** When the xShmLock method is invoked by SQLite, the following script is
** run:
**
**   SCRIPT xShmLock    FILENAME ID LOCK
**
** where LOCK is of the form "OFFSET NBYTE lock/unlock shared/exclusive"
*/
static int testvfs_cmd(
  ClientData cd,
  Tcl_Interp interp,
  int objc,
  Tcl_Obj[] objv
){
  Debugger.Break();//TODO
//  sqlite3_vfs tvfs_vfs = new sqlite3_vfs(
//    2,                            /* iVersion */
//    0,                            /* szOsFile */
//    0,                            /* mxPathname */
//    null,                         /* pNext */
//    null,                            /* zName */
//    0,                            /* pAppData */
//    tvfsOpen,                     /* xOpen */
//    tvfsDelete,                   /* xDelete */
//    tvfsAccess,                   /* xAccess */
//    tvfsFullPathname,             /* xFullPathname */
//#if !SQLITE_OMIT_LOAD_EXTENSION
//    tvfsDlOpen,                   /* xDlOpen */
//    tvfsDlError,                  /* xDlError */
//    tvfsDlSym,                    /* xDlSym */
//    tvfsDlClose,                  /* xDlClose */
//#else
//    null,                            /* xDlOpen */
//    null,                            /* xDlError */
//    null,                            /* xDlSym */
//    null,                            /* xDlClose */
//#endif //* SQLITE_OMIT_LOAD_EXTENSION */
//    tvfsRandomness,               /* xRandomness */
//    tvfsSleep,                    /* xSleep */
//    tvfsCurrentTime,              /* xCurrentTime */
//    null,                         /* xGetLastError */
//    null,                          /* xCurrentTimeInt64 */
//    null, null, null
//    );

//  Testvfs p;                     /* New object */
//  sqlite3_vfs pVfs;              /* New VFS */
//  string zVfs;
//  int nByte;                      /* Bytes of space to allocate at p */

//  int i;
//  int isNoshm = 0;                /* True if -noshm is passed */
//  int isDefault = 0;              /* True if -default is passed */
//  int szOsFile = 0;               /* Value passed to -szosfile */
//  int mxPathname = -1;            /* Value passed to -mxpathname */
//  int iVersion = 2;               /* Value passed to -iversion */

//  if( objc<2 || 0!=(objc%2) ) goto bad_args;
//  for(i=2; i<objc; i += 2){
//    int nSwitch;
//    string zSwitch;
//    zSwitch = TCL.Tcl_GetStringFromObj(objv[i], &nSwitch); 

//    if( nSwitch>2 && 0==strncmp("-noshm", zSwitch, nSwitch) ){
//      if ( TCL.Tcl_GetBooleanFromObj( interp, objv[i + 1], &isNoshm ) )
//      {
//        return TCL.TCL_ERROR;
//      }
//    }
//    else if( nSwitch>2 && 0==strncmp("-default", zSwitch, nSwitch) ){
//      if ( TCL.Tcl_GetBooleanFromObj( interp, objv[i + 1], &isDefault ) )
//      {
//        return TCL.TCL_ERROR;
//      }
//    }
//    else if( nSwitch>2 && 0==strncmp("-szosfile", zSwitch, nSwitch) ){
//      if ( TCL.Tcl_GetIntFromObj( interp, objv[i + 1], &szOsFile ) )
//      {
//        return TCL.TCL_ERROR;
//      }
//    }
//    else if( nSwitch>2 && 0==strncmp("-mxpathname", zSwitch, nSwitch) ){
//      if ( TCL.Tcl_GetIntFromObj( interp, objv[i + 1], &mxPathname ) )
//      {
//        return TCL.TCL_ERROR;
//      }
//    }
//    else if( nSwitch>2 && 0==strncmp("-iversion", zSwitch, nSwitch) ){
//      if ( TCL.Tcl_GetIntFromObj( interp, objv[i + 1], &iVersion ) )
//      {
//        return TCL.TCL_ERROR;
//      }
//    }
//    else{
//      goto bad_args;
//    }
//  }

//  if( szOsFile<sizeof(TestvfsFile) ){
//    szOsFile = sizeof(TestvfsFile);
//  }

//  zVfs = TCL.Tcl_GetString(objv[1]);
//  nByte = sizeof(Testvfs) + strlen(zVfs)+1;
//  p = (Testvfs )ckalloc(nByte);
//  memset(p, 0, nByte);
//  p.iDevchar = -1;
//  p.iSectorsize = -1;

//  /* Create the new object command before querying SQLite for a default VFS
//  ** to use for 'real' IO operations. This is because creating the new VFS
//  ** may delete an existing [testvfs] VFS of the same name. If such a VFS
//  ** is currently the default, the new [testvfs] may end up calling the 
//  ** methods of a deleted object.
//  */
//  TCL.Tcl_CreateObjCommand( interp, zVfs, testvfs_obj_cmd, p, testvfs_obj_del );
//  p.pParent = sqlite3_vfs_find("");
//  p.interp = interp;

//  p.zName = (char )&p[1];
//  memcpy(p.zName, zVfs, strlen(zVfs)+1);

//  pVfs = new sqlite3_vfs();//(sqlite3_vfs )ckalloc(sizeof(sqlite3_vfs));
//  tvfs_vfs.CopyTo(pVfs);//memcpy( pVfs, &tvfs_vfs, sizeof( sqlite3_vfs ) );
//  pVfs.pAppData = p;
//  pVfs.iVersion = iVersion;
//  pVfs.zName = p.zName;
//  pVfs.mxPathname = p.pParent.mxPathname;
//  if( mxPathname>=0 && mxPathname<pVfs.mxPathname ){
//    pVfs.mxPathname = mxPathname;
//  }
//  pVfs.szOsFile = szOsFile;
//  p.pVfs = pVfs;
//  p.isNoshm = isNoshm;
//  p.mask = TESTVFS_ALL_MASK;

//  sqlite3_vfs_register(pVfs, isDefault);

//  return TCL.TCL_OK;

// bad_args:
//  TCL.Tcl_WrongNumArgs(interp, 1, objv, "VFSNAME ?-noshm BOOL? ?-default BOOL? ?-mxpathname INT? ?-szosfile INT? ?-iversion INT?");
  return TCL.TCL_ERROR;
}
        protected virtual void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId,uint timestamp)
        {
            m_clientUpdateFlag[clientId] = true;

            ClientData data = new ClientData();
            data.TimeStamp = timestamp;
            data.Transform = new MyTransformD();

            data.Transform.Rotation = stream.ReadQuaternionNorm();
            data.Transform.Position = stream.ReadVector3D();

            m_serverClientData[clientId] = data;        
        }
Beispiel #15
0
static int testvfs_obj_cmd(
  ClientData cd,
  Tcl_Interp interp,
  int objc,
  Tcl_Obj[] objv
){
  Debugger.Break();//TODO
//  Testvfs p = (Testvfs)cd;

// TestvfsSubcmd[] aSubcmd = new TestvfsSubcmd[]  {
//    new TestvfsSubcmd( "shm",         DB_enum_CMD.CMD_SHM         ),
//    new TestvfsSubcmd( "delete",      DB_enum_CMD.CMD_DELETE      ),
//    new TestvfsSubcmd( "filter",      DB_enum_CMD.CMD_FILTER      ),
//    new TestvfsSubcmd( "ioerr",       DB_enum_CMD.CMD_IOERR       ),
//    new TestvfsSubcmd( "fullerr",     DB_enum_CMD.CMD_FULLERR     ),
//    new TestvfsSubcmd( "cantopenerr", DB_enum_CMD.CMD_CANTOPENERR ),
//    new TestvfsSubcmd( "script",      DB_enum_CMD.CMD_SCRIPT      ),
//    new TestvfsSubcmd( "devchar",     DB_enum_CMD.CMD_DEVCHAR     ),
//    new TestvfsSubcmd( "sectorsize",  DB_enum_CMD.CMD_SECTORSIZE  ),
//    new TestvfsSubcmd( 0, 0 )
//  };
//  int i=0;
  
//  if( objc<2 ){
//    TCL.Tcl_WrongNumArgs( interp, 1, objv, "SUBCOMMAND ..." );
//    return TCL.TCL_ERROR;
//  }
//  if ( TCL.Tcl_GetIndexFromObjStruct(
//        interp, objv[1], aSubcmd, aSubcmd.Length, "subcommand", 0, ref i) 
//  ){
//    return TCL.TCL_ERROR;
//  }
//  TCL.Tcl_ResetResult( interp );

//  switch( aSubcmd[i].eCmd ){
//    case DB_enum_CMD.CMD_SHM: {
//      Tcl_Obj pObj;
//      int i;
//      TestvfsBuffer pBuffer;
//      string zName;
//      if( objc!=3 && objc!=4 ){
//        TCL.Tcl_WrongNumArgs( interp, 2, objv, "FILE ?VALUE?" );
//        return TCL.TCL_ERROR;
//      }
//      zName = ckalloc(p.pParent.mxPathname);
//      p.pParent.xFullPathname(
//          p.pParent, TCL.Tcl_GetString(objv[2]), 
//          p.pParent.mxPathname, zName
//      );
//      for(pBuffer=p.pBuffer; pBuffer; pBuffer=pBuffer.pNext){
//        if( 0==strcmp(pBuffer.zFile, zName) ) break;
//      }
//      ckfree(zName);
//      if( null==pBuffer ){
//        TCL.Tcl_AppendResult( interp, "no such file: ", TCL.Tcl_GetString( objv[2] ), 0 );
//        return TCL.TCL_ERROR;
//      }
//      if( objc==4 ){
//        int n;
//        u8 *a = TCL.Tcl_GetByteArrayFromObj(objv[3], &n);
//        int pgsz = pBuffer.pgsz;
//        if( pgsz==0 ) pgsz = 65536;
//        for(i=0; ipgsz<n; i++){
//          int nByte = pgsz;
//          tvfsAllocPage(pBuffer, i, pgsz);
//          if( n-ipgsz<pgsz ){
//            nByte = n;
//          }
//          memcpy(pBuffer.aPage[i], &a[ipgsz], nByte);
//        }
//      }

//      pObj = TCL.Tcl_NewObj();
//      for(i=0; pBuffer.aPage[i]!=null; i++){
//        int pgsz = pBuffer.pgsz;
//        if( pgsz==0 ) pgsz = 65536;
//        TCL.Tcl_AppendObjToObj(pObj, TCL.Tcl_NewByteArrayObj(pBuffer.aPage[i], pgsz));
//      }
//      TCL.Tcl_SetObjResult( interp, pObj );
//      break;
//    }    
//    case DB_enum_CMD.CMD_FILTER: {
//VfsMethod[] vfsmethod = new VfsMethod[] {
//        new VfsMethod( "xShmOpen",      TESTVFS_SHMOPEN_MASK ),
//        new VfsMethod( "xShmLock",      TESTVFS_SHMLOCK_MASK ),
//        new VfsMethod( "xShmBarrier",   TESTVFS_SHMBARRIER_MASK ),
//        new VfsMethod( "xShmUnmap",     TESTVFS_SHMCLOSE_MASK ),
//        new VfsMethod( "xShmMap",       TESTVFS_SHMMAP_MASK ),
//        new VfsMethod( "xSync",         TESTVFS_SYNC_MASK ),
//        new VfsMethod( "xDelete",       TESTVFS_DELETE_MASK ),
//        new VfsMethod( "xWrite",        TESTVFS_WRITE_MASK ),
//        new VfsMethod( "xTruncate",     TESTVFS_TRUNCATE_MASK ),
//        new VfsMethod( "xOpen",         TESTVFS_OPEN_MASK ),
//        new VfsMethod( "xClose",        TESTVFS_CLOSE_MASK ),
//        new VfsMethod( "xAccess",       TESTVFS_ACCESS_MASK ),
//        new VfsMethod( "xFullPathname", TESTVFS_FULLPATHNAME_MASK ),
//};
//      Tcl_Obj[] apElem = null;
//      int nElem = 0;
//      int i;
//      int mask = 0;
//      if( objc!=3 ){
//        TCL.Tcl_WrongNumArgs( interp, 2, objv, "LIST" );
//        return TCL.TCL_ERROR;
//      }
//      if ( TCL.Tcl_ListObjGetElements( interp, objv[2], ref nElem, ref apElem ) )
//      {
//        return TCL.TCL_ERROR;
//      }
//      TCL.Tcl_ResetResult( interp );
//      for(i=0; i<nElem; i++){
//        int iMethod;
//        string zElem = TCL.Tcl_GetString(apElem[i]);
//        for(iMethod=0; iMethod<ArraySize(vfsmethod); iMethod++){
//          if( strcmp(zElem, vfsmethod[iMethod].zName)==0 ){
//            mask |= vfsmethod[iMethod].mask;
//            break;
//          }
//        }
//        if( iMethod==ArraySize(vfsmethod) ){
//          TCL.Tcl_AppendResult( interp, "unknown method: ", zElem, 0 );
//          return TCL.TCL_ERROR;
//        }
//      }
//      p.mask = mask;
//      break;
//    }

//    case DB_enum_CMD.CMD_SCRIPT: {
//      if( objc==3 ){
//        int nByte;
//        if( p.pScript !=null){
//          TCL.Tcl_DecrRefCount( p.pScript );
//          p.pScript = 0;
//        }
//        TCL.Tcl_GetStringFromObj( objv[2], &nByte );
//        if( nByte>0 ){
//          p.pScript = TCL.Tcl_DuplicateObj(objv[2]);
//          TCL.Tcl_IncrRefCount( p.pScript );
//        }
//      }else if( objc!=2 ){
//        TCL.Tcl_WrongNumArgs( interp, 2, objv, "?SCRIPT?" );
//        return TCL.TCL_ERROR;
//      }

//      TCL.Tcl_ResetResult( interp );
//      if( p.pScript !=null) if( p.pScript )TCL.Tcl_SetObjResult(interp, p.pScript);

//      break;
//    }

//    /*
//    ** TESTVFS ioerr ?IFAIL PERSIST?
//    **
//    **   Where IFAIL is an integer and PERSIST is boolean.
//    */
//    case DB_enum_CMD.CMD_CANTOPENERR:
//    case DB_enum_CMD.CMD_IOERR:
//    case DB_enum_CMD.CMD_FULLERR: {
//      TestFaultInject pTest;
//      int iRet;

//      switch( aSubcmd[i].eCmd ){
//        case DB_enum_CMD.CMD_IOERR: pTest = p.ioerr_err; break;
//        case DB_enum_CMD.CMD_FULLERR: pTest = p.full_err; break;
//        case DB_enum_CMD.CMD_CANTOPENERR: pTest = p.cantopen_err; break;
//        default: Debug.Assert(false);
//      }
//      iRet = pTest.nFail;
//      pTest.nFail = 0;
//      pTest.eFault = 0;
//      pTest.iCnt = 0;

//      if( objc==4 ){
//        int iCnt, iPersist;
//        if ( TCL.TCL_OK != TCL.Tcl_GetIntFromObj( interp, objv[2], &iCnt )
//         || TCL.TCL_OK != TCL.Tcl_GetBooleanFromObj( interp, objv[3], &iPersist )
//        ){
//          return TCL.TCL_ERROR;
//        }
//        pTest.eFault = iPersist != 0 ? FAULT_INJECT_PERSISTENT : FAULT_INJECT_TRANSIENT;
//        pTest.iCnt = iCnt;
//      }else if( objc!=2 ){
//        TCL.Tcl_WrongNumArgs( interp, 2, objv, "?CNT PERSIST?" );
//        return TCL.TCL_ERROR;
//      }
//      TCL.Tcl_SetObjResult( interp, TCL.Tcl_NewIntObj( iRet ) );
//      break;
//    }

//    case DB_enum_CMD.CMD_DELETE: {
//      TCL.Tcl_DeleteCommand( interp, TCL.Tcl_GetString( objv[0] ) );
//      break;
//    }

//    case DB_enum_CMD.CMD_DEVCHAR: {
//_aFlag[] aFlag = new _aFlag[] {
//        new _aFlag( "default",               -1 ),
//        new _aFlag( "atomic",                SQLITE_IOCAP_ATOMIC      ),
//        new _aFlag( "atomic512",             SQLITE_IOCAP_ATOMIC512   ),
//        new _aFlag( "atomic1k",              SQLITE_IOCAP_ATOMIC1K    ),
//        new _aFlag( "atomic2k",              SQLITE_IOCAP_ATOMIC2K    ),
//        new _aFlag( "atomic4k",              SQLITE_IOCAP_ATOMIC4K    ),
//        new _aFlag( "atomic8k",              SQLITE_IOCAP_ATOMIC8K    ),
//        new _aFlag( "atomic16k",             SQLITE_IOCAP_ATOMIC16K   ),
//        new _aFlag( "atomic32k",             SQLITE_IOCAP_ATOMIC32K   ),
//        new _aFlag( "atomic64k",             SQLITE_IOCAP_ATOMIC64K   ),
//        new _aFlag( "sequential",            SQLITE_IOCAP_SEQUENTIAL  ),
//        new _aFlag( "safe_append",           SQLITE_IOCAP_SAFE_APPEND ),
//        new _aFlag( "undeletable_when_open", SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN ),
//        new _aFlag( 0, 0 )
//      };
//      Tcl_Obj pRet;
//      int iFlag;

//      if( objc>3 ){
//        Tcl_WrongNumArgs(interp, 2, objv, "?ATTR-LIST?");
//        return TCL.TCL_ERROR;
//      }
//      if( objc==3 ){
//        int j;
//        int iNew = 0;
//        Tcl_Obj[] flags = null;
//        int nFlags = 0;

//        if ( TCL.Tcl_ListObjGetElements( interp, objv[2], ref nFlags, ref flags ) )
//        {
//          return TCL.TCL_ERROR;
//        }

//        for(j=0; j<nFlags; j++){
//          int idx = 0;
//          if( Tcl_GetIndexFromObjStruct(interp, flags[j], aFlag, 
//                aFlag.Length, "flag", 0, ref idx) 
//          ){
//            return TCL.TCL_ERROR;
//          }
//          if( aFlag[idx].iValue<0 && nFlags>1 ){
//            TCL.Tcl_AppendResult( interp, "bad flags: ", TCL.Tcl_GetString( objv[2] ), 0 );
//            return TCL.TCL_ERROR;
//          }
//          iNew |= aFlag[idx].iValue;
//        }

//        p.iDevchar = iNew;
//      }

//      pRet = TCL.Tcl_NewObj();
//      for(iFlag=0; iFlag<aFlag.Length ; iFlag++)//sizeof(aFlag)/sizeof(aFlag[0]); iFlag++)
//      {
//        if( p.iDevchar & aFlag[iFlag].iValue ){
//          TCL.Tcl_ListObjAppendElement(
//              interp, pRet, TCL.Tcl_NewStringObj(aFlag[iFlag].zName, -1)
//          );
//        }
//      }
//      TCL.Tcl_SetObjResult( interp, pRet );

//      break;
//    }

//    case DB_enum_CMD.CMD_SECTORSIZE: {
//      if( objc>3 ){
//        TCL.Tcl_WrongNumArgs( interp, 2, objv, "?VALUE?" );
//        return TCL.TCL_ERROR;
//      }
//      if( objc==3 ){
//        int iNew = 0;
//        if( Tcl_GetIntFromObj(interp, objv[2], ref iNew) ){
//          return TCL.TCL_ERROR;
//        }
//        p.iSectorsize = iNew;
//      }
//      TCL.Tcl_SetObjResult( interp, TCL.Tcl_NewIntObj( p.iSectorsize ) );
//      break;
//    }
//  }
  return TCL.TCL_OK;
}
Beispiel #16
0
 /*
 ** Register the echo virtual table module.
 */
 static int register_echo_module(
   ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
   Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
   int objc,              /* Number of arguments */
   Tcl_Obj[] objv  /* Command arguments */
 )
 {
   sqlite3 db = null;
   ;
   ;
   EchoModule pMod;
   if ( objc != 2 )
   {
     TCL.Tcl_WrongNumArgs( interp, 1, objv, "DB" );
     return TCL.TCL_ERROR;
   }
   if ( getDbPointer( interp, TCL.Tcl_GetString( objv[1] ), out db ) != 0 )
     return TCL.TCL_ERROR;
   pMod = new EchoModule();//sqlite3_malloc(sizeof(EchoModule));
   pMod.interp = interp;
   sqlite3_create_module_v2( db, "echo", echoModule, pMod, moduleDestroy );
   return TCL.TCL_OK;
 }
 private void RemoveForClient(IMyReplicable replicable, EndpointId clientEndpoint, ClientData clientData, bool sendDestroyToClient)
 {
     if (sendDestroyToClient)
     {
         SendReplicationDestroy(replicable, clientEndpoint);
     }
     RemoveClientReplicable(replicable, clientData);
     Console.WriteLine(String.Format("Sending replication destroy: {0}", GetNetworkIdByObject(replicable)));
 }
        private void AddClientReplicable(IMyReplicable replicable, ClientData clientData)
        {
            // Add replicable
            clientData.Replicables.Add(replicable, new MyReplicableClientData());

            // Add state groups
            foreach (var group in m_replicableGroups[replicable])
            {
                var netId = GetNetworkIdByObject(group);
                clientData.StateGroups.Add(group, new MyStateDataEntry(replicable, netId, group));
                group.CreateClientData(clientData.State);
            }
        }
Beispiel #19
0
		public PlayData(BotSession session, ClientData invoker, string message, bool enqueue)
		{
			Session = session;
			Invoker = invoker;
			Message = message;
			Enqueue = enqueue;
			Resource = null;
			Volume = -1;
		}
    /*****************************************************************************
    ** Everything below is interface for testing this module.
    */
#if SQLITE_TEST
    //#include <tcl.h>

    /*
    ** Routines to encode and decode pointers
    */
    //extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
    //extern void *sqlite3TestTextToPtr(const char*);
    //extern int sqlite3TestMakePointerStr(Tcl_Interp*, char *zPtr, void*);
    //extern const char *sqlite3TestErrorName(int);

    /*
    **    sqlite3_intarray_create  DB  NAME
    **
    ** Invoke the sqlite3_intarray_create interface.  A string that becomes
    ** the first parameter to sqlite3_intarray_bind.
    */
    static int test_intarray_create(
      ClientData clientData, /* Not used */
      Tcl_Interp interp,     /* The TCL interpreter that invoked this command */
      int objc,              /* Number of arguments */
      Tcl_Obj[] objv         /* Command arguments */
    )
    {
      sqlite3 db;
      string zName;
      sqlite3_intarray pArray;
      int rc = SQLITE_OK;
      StringBuilder zPtr = new StringBuilder( 100 );

      if ( objc != 3 )
      {
        TCL.Tcl_WrongNumArgs( interp, 1, objv, "DB" );
        return TCL.TCL_ERROR;
      }
      if ( getDbPointer( interp, TCL.Tcl_GetString( objv[1] ), out db ) != 0 )
        return TCL.TCL_ERROR;
      zName = TCL.Tcl_GetString( objv[2] );
#if !SQLITE_OMIT_VIRTUALTABLE
      rc = sqlite3_intarray_create( db, zName, out pArray );
#endif
      if ( rc != SQLITE_OK )
      {
        Debug.Assert( pArray == null );
        TCL.Tcl_AppendResult( interp, sqlite3TestErrorName( rc ), null );
        return TCL.TCL_ERROR;
      }
      sqlite3TestMakePointerStr( interp, zPtr, pArray );
      TCL.Tcl_AppendResult( interp, zPtr, null );
      return TCL.TCL_OK;
    }
        //internal void ResetPriorities(EndpointId endpointId)
        //{
        //    Debug.Assert(m_clientStates.ContainsKey(endpointId));
        //    foreach (var entry in m_clientStates[endpointId].StateGroups.Values)
        //    {
        //        entry.ResetPriority();
        //    }
        //}

        // Event dispatch:
        // 1) Reliable events are sent immediatelly when client has replicable or state group
        // 2) Unreliable events are added into queue with priority (they added only for relevant replicated objects or state groups)
        bool ShouldSendEvent(IMyNetObject eventInstance, bool isReliable, ClientData client, out float priority)
        {
            if (eventInstance == null)
            {
                // Static event
                priority = 1;
                return true;
            }

            MyStateDataEntry entry;
            MyReplicableClientData replicableInfo;
            if ((eventInstance is IMyStateGroup && client.StateGroups.TryGetValue((IMyStateGroup)eventInstance, out entry)))
            {
                // For state group, priority cannot be inherited, because it's changing with time
                // Maybe add another method IMyStateGroup.GetEventPriority()
                replicableInfo = client.Replicables[entry.Owner];
                priority = 1;
                return isReliable || replicableInfo.HasActiveStateSync;
            }
            else if (eventInstance is IMyReplicable && (client.Replicables.TryGetValue((IMyReplicable)eventInstance, out replicableInfo) || m_fixedObjects.Contains(eventInstance)))
            {
                // Event inherits replicated object priority
                priority = ((IMyReplicable)eventInstance).GetPriority(client.State);
                return isReliable || (priority > 0 && replicableInfo.HasActiveStateSync);
            }
            else
            {
                priority = 0;
                return false;
            }
        }
 private void RemoveClientReplicable(IMyReplicable replicable, ClientData clientData)
 {
     foreach (var g in m_replicableGroups[replicable])
     {
         g.DestroyClientData(clientData.State);
         clientData.StateGroups.Remove(g);
     }
     clientData.Replicables.Remove(replicable);
 }
    /*
    **    sqlite3_intarray_bind  INTARRAY  ?VALUE ...?
    **
    ** Invoke the sqlite3_intarray_bind interface on the given array of integers.
    */
    static int test_intarray_bind(
      ClientData clientData, /* Not used */
      Tcl_Interp interp,     /* The TCL interpreter that invoked this command */
      int objc,              /* Number of arguments */
      Tcl_Obj[] objv         /* Command arguments */
    )
    {
      sqlite3_intarray pArray;
      int rc = SQLITE_OK;
      int i, n;
      sqlite3_int64[] a;

      if ( objc < 2 )
      {
        TCL.Tcl_WrongNumArgs( interp, 1, objv, "INTARRAY" );
        return TCL.TCL_ERROR;
      }
      pArray = (sqlite3_intarray)sqlite3TestTextToPtr( interp, TCL.Tcl_GetString( objv[1] ) );
      n = objc - 2;
#if !SQLITE_OMIT_VIRTUALTABLE
      a = new sqlite3_int64[n];//sqlite3_malloc( sizeof(a[0])*n );
      //if( a==0 ){
      //  Tcl_AppendResult(interp, "SQLITE_NOMEM", (char*)0);
      //  return TCL_ERROR;
      //}
      for ( i = 0; i < n; i++ )
      {
        //a[i] = 0;
        TCL.Tcl_GetWideIntFromObj( null, objv[i + 2], out a[i] );
      }
      rc = sqlite3_intarray_bind( pArray, n, a, sqlite3_free );
      if ( rc != SQLITE_OK )
      {
        TCL.Tcl_AppendResult( interp, sqlite3TestErrorName( rc ), null );
        return TCL.TCL_ERROR;
      }
#endif
      return TCL.TCL_OK;
    }
Beispiel #24
0
        static void RecvClient()
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            socket.Bind(new IPEndPoint(IPAddress.Any, 10001));
            EndPoint iep1 = new IPEndPoint(IPAddress.Broadcast, 10001);
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
            byte[] buffer = new byte[1024];
            while (true)
            {
                var count = socket.ReceiveFrom(buffer, ref iep1);

                string msg = Encoding.ASCII.GetString(buffer, 0, count);
                if (msg == "MultySSH")
                {

                    ClientData cd = new ClientData();
                    cd.ip = ((IPEndPoint)iep1).Address.ToString();
                    cd.username = "root";
                    cd.password = "[email protected]#$%12345";

                    var c = (from j in clients where j.ip == cd.ip select j).FirstOrDefault();
                    if(c== null)
                    {
                        clients.Add(cd);
                    }
                }
            }
        }
		public int[] GetClientServerGroups(ClientData client)
		{
			if (client == null)
				throw new ArgumentNullException(nameof(client));

			Log.Write(Log.Level.Debug, "QC GetClientServerGroups called");
			var response = tsClient.ServerGroupsOfClientDbId(client);
			if (!response.Any())
				return new int[0];
			return response.Select(csg => csg.ServerGroupId).ToArray();
		}
Beispiel #26
0
        static void RunCommand(ClientData client)
        {
            IClient cli = new Client2(client.ip, client.username, client.password);
            cli.Connect();

            Console.WriteLine();
            Console.WriteLine(client.ip + " Running...");

            foreach (var cmd in command)
            {
                cli.WaitForIdle();
                cli.SendCommand(cmd);
            }

            cli.WaitForIdle();

            cli.Disconnect();
            cli = null;

            Console.WriteLine();
            Console.WriteLine(client.ip + " Finished...");
        }
		public void SendMessage(string message, ClientData client) => tsClient.SendMessage(message, client);
Beispiel #28
0
        static void ReadConfig()
        {
            var fileStream = System.IO.File.Open(System.IO.Directory.GetCurrentDirectory() + "/server.txt", System.IO.FileMode.Open);
            StreamReader reader = new StreamReader(fileStream);
            while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();
                if (line.StartsWith("#") || string.IsNullOrEmpty(line))
                    continue;

                line = line.TrimStart(' ').TrimEnd(' ');

                if (line.StartsWith("sh"))
                {
                    string cmd = line.Substring(3);
                    command.Add(cmd);
                }
                else
                {
                    var datas = line.Split(' ');
                    if (datas.Length < 3) continue;

                    ClientData cdata = new ClientData();

                    cdata.ip = datas[0];
                    cdata.username = datas[1];
                    cdata.password = datas[2];

                    clients.Add(cdata);

                }
            }
        }
Beispiel #29
0
 /*
 ** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl:
 **
 ** sqlite3_declare_vtab DB SQL
 */
 static int declare_vtab(
   ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
   Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
   int objc,              /* Number of arguments */
   Tcl_Obj[] objv  /* Command arguments */
 )
 {
   sqlite3 db = null;
   int rc;
   if ( objc != 3 )
   {
     TCL.Tcl_WrongNumArgs( interp, 1, objv, "DB SQL" );
     return TCL.TCL_ERROR;
   }
   if ( getDbPointer( interp, TCL.Tcl_GetString( objv[1] ), out db ) != 0 )
     return TCL.TCL_ERROR;
   rc = sqlite3_declare_vtab( db, TCL.Tcl_GetString( objv[2] ) );
   if ( rc != SQLITE_OK )
   {
     TCL.Tcl_SetResult( interp, sqlite3_errmsg( db ), TCL.TCL_VOLATILE );
     return TCL.TCL_ERROR;
   }
   return TCL.TCL_OK;
 }
/*
** Decode a pointer to an sqlite3 object.
*/
//extern int getDbPointer(Tcl_Interp *interp, string zA, sqlite3 **ppDb);

/*
** Register the echo virtual table module.
*/
static int register_tclvar_module(
  ClientData clientData,/* Pointer to sqlite3_enable_XXX function */
  Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
  int objc,             /* Number of arguments */
  Tcl_Obj[] objv        /* Command arguments */
){
  sqlite3 db=null;
  if( objc!=2 ){
    TCL.Tcl_WrongNumArgs(interp, 1, objv, "DB");
    return TCL.TCL_ERROR;
  }
  if( getDbPointer(interp, TCL.Tcl_GetString(objv[1]), out db) !=0) return TCL.TCL_ERROR;
#if !SQLITE_OMIT_VIRTUALTABLE
  sqlite3_create_module(db, "tclvar", tclvarModule, interp);
#endif
  return TCL.TCL_OK;
}