String join( StringRef sep, const VecString& vs ) { String j; VecString::const_iterator i = vs.begin(); if( i != vs.end() ) j = *i++; while( i != vs.end() ) j += sep + *i++; return j; }
void CRedisClient::subscribeStart(const VecString &channel, int timeout) { Command cmd( "SUBSCRIBE" ); VecString::const_iterator it = channel.begin(); for ( ; it != channel.end(); ++it ) { cmd << *it ; } Poco::Timespan t(timeout, 0); _socket.setReceiveTimeout(t); CResult result; _getArry(cmd, result); }
uint64_t CRedisClient::psubnumsub( CRedisClient::MapString& value, const VecString& channel ) { Command cmd( "PUBSUB" ); cmd << "NUMSUB"; if ( channel.size() != 0 ) { VecString::const_iterator it = channel.begin(); for ( ; it != channel.end(); ++it ) { cmd << *it ; } } return _getArry( cmd, value ); }
ListDevice getDevices() { ListDevice devs; String ccs = "SYSTEM\\CurrentControlSet\\"; RegKey dclass( HKEY_LOCAL_MACHINE, ccs+"Control\\DeviceClasses" ); RegKey ftdibus( HKEY_LOCAL_MACHINE, ccs+"Enum\\FTDIBUS" ); RegKey usb6001( HKEY_LOCAL_MACHINE, ccs+"Enum\\USB\\Vid_0403&Pid_6001" ); VecString fdev = ftdibus.getSubkeyNames(); for( VecString::const_iterator i=fdev.begin(); i!=fdev.end(); i++ ) { if( i->substr(0,18) == String("VID_0403+PID_6001+") ) { Device d; d.id = i->substr(18,8); try { RegKey devkey = ftdibus[*i]; VecString devsub = devkey.getSubkeyNames(); d.comm = devkey[devsub[0]+"\\Device Parameters"]("PortName").data; } catch( std::runtime_error e ) { d.comm = "no_comm"; } try { d.info = usb6001[d.id]("LocationInformation").data; } catch( std::runtime_error e ) { } try { d.refcount = getRefCount( dclass, usb6001[d.id] ); } catch( std::runtime_error e ) { } String::size_type ncomm = d.comm.find_first_of("0123456789"); if( ncomm != String::npos ) d.sortnum = atoi( d.comm.substr(ncomm).c_str() ); devs.push_back(d); } } return devs; }
uint64_t CRedisClient::psubchannels( VecString& value, const VecString& pattern ) { Command cmd( "PUBSUB" ); cmd << "CHANNELS"; if ( pattern.size() != 0 ) { VecString::const_iterator it = pattern.begin(); for ( ; it != pattern.end(); ++it ) { cmd << *it ; } } return _getArry( cmd, value ); }
void CRedisClient::punsubscribe( CResult& result, const VecString& pattern ) { _socket.clearBuffer(); Command cmd( "PUNSUBSCRIBE" ); if ( pattern.size() != 0 ) { VecString::const_iterator it = pattern.begin(); for ( ; it != pattern.end(); ++it ) { cmd << *it ; } } _sendCommand( cmd ); _getReply( result ); }
void CRedisClient::psubscribe( const VecString& pattern, CResult& result) { Command cmd( "PSUBSCRIBE" ); VecString::const_iterator it = pattern.begin(); for ( ; it != pattern.end(); ++it ) { cmd << *it; } _socket.setReceiveTimeout(0); result.clear(); _getArry( cmd, result ); while(true) { result.clear(); _getReply( result ); } }
void CRedisClient::unsubscribe( CResult& result, const VecString& channel ) { _socket.clearBuffer(); Command cmd( "UNSUBSCRIBE" ); if ( channel.size() != 0 ) { VecString::const_iterator it = channel.begin(); for ( ; it != channel.end(); ++it ) { cmd << *it ; } } _sendCommand( cmd ); _getResult( cmd, result ); }