本文整理汇总了C++中ClientConnect函数的典型用法代码示例。如果您正苦于以下问题:C++ ClientConnect函数的具体用法?C++ ClientConnect怎么用?C++ ClientConnect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClientConnect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void GateModule::handle_message(const message& msg)
{
switch (msg.get_type())
{
case EMessageType::SocketConnect:
{
ClientConnect(msg);
break;
}
case EMessageType::SocketData:
{
ClientData(msg);
break;
}
case EMessageType::SocketClose:
{
ClientClose(msg);
break;
}
case EMessageType::ActorData:
{
ActorData(msg);
break;
}
case EMessageType::ToClient:
{
ToClientData(msg);
break;
}
}
}
示例2: Client
void Client(char *filename)
{
int clientSocketDescriptor;
int connectResult;
FILE *rdfile;
rdfile = fopen(filename, "r");
if (rdfile == NULL)
{
puts ("Error while opening file.");
return;
}
clientSocketDescriptor = StartClient("tcp");
connectResult = ClientConnect(clientSocketDescriptor, "127.0.0.1", 6660);
if (connectResult == -1)
{
return;
}
if (SendFileName(clientSocketDescriptor, filename) == -1)
{
return;
}
if (SendFileSize(clientSocketDescriptor, rdfile) == -1)
{
return;
}
ClientProcess(clientSocketDescriptor, rdfile);
ShutdownSocket(clientSocketDescriptor);
CloseSocket(clientSocketDescriptor);
fclose(rdfile);
return;
}
示例3: SSL_library_load
SslHandle *NetlibSslConnect(SOCKET s, const char* host, int verify)
{
/* negotiate SSL session, verify cert, return NULL if failed */
bool res = SSL_library_load();
if (!res)
return NULL;
SslHandle *ssl = (SslHandle*)mir_calloc(sizeof(SslHandle));
ssl->s = s;
res = ClientConnect(ssl, host);
if (res && verify) {
DWORD dwFlags = 0;
if (!host || inet_addr(host) != INADDR_NONE)
dwFlags |= 0x00001000;
res = VerifyCertificate(ssl, host, dwFlags);
}
if(res) {
return ssl;
}
else {
NetlibSslFree(ssl);
return NULL;
}
}
示例4: BOT_SpawnBot
///////////////////////////////////////////////////////////////////////
// Spawn the bot
///////////////////////////////////////////////////////////////////////
void BOT_SpawnBot (char *team, char *name, char *skin, char *userinfo)
{
edict_t *bot;
if( !nav.loaded ) {
Com_Printf("Can't spawn bots without a valid navigation file\n");
return;
}
bot = BOT_FindFreeClient ();
if (!bot)
{
safe_bprintf (PRINT_MEDIUM, "Server is full, increase Maxclients.\n");
return;
}
//init the bot
bot->inuse = true;
bot->yaw_speed = 100;
// To allow bots to respawn
if(userinfo == NULL)
BOT_SetName(bot, name, skin, team);
else
ClientConnect (bot, userinfo);
G_InitEdict (bot);
G_SpawnAI(bot); //jabot092(2)
bot->ai->is_bot = true;
InitClientResp (bot->client);
PutClientInServer(bot);
BOT_StartAsSpectator (bot);
//skill
bot->ai->pers.skillLevel = (int)(random()*MAX_BOT_SKILL);
if (bot->ai->pers.skillLevel > MAX_BOT_SKILL) //fix if off-limits
bot->ai->pers.skillLevel = MAX_BOT_SKILL;
else if (bot->ai->pers.skillLevel < 0)
bot->ai->pers.skillLevel = 0;
BOT_DMclass_InitPersistant(bot);
AI_ResetWeights(bot);
AI_ResetNavigation(bot);
bot->think = BOT_JoinGame;
bot->nextthink = level.time + (int)(random()*6.0);
if( ctf->value && team != NULL )
{
if( !Q_stricmp( team, "blue" ) )
bot->think = BOT_JoinBlue;
else if( !Q_stricmp( team, "red" ) )
bot->think = BOT_JoinRed;
}
AI_EnemyAdded (bot); // let the ai know we added another
}
示例5: My_ClientConnect
char* __cdecl My_ClientConnect(int clientNum, qboolean firstTime, qboolean isBot) {
if (firstTime) {
char* res = ClientConnectDispatcher(clientNum, isBot);
if (res && !isBot) {
return res;
}
}
return ClientConnect(clientNum, firstTime, isBot);
}
示例6: baseq3_qagame_vmMain
int baseq3_qagame_vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
#else
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
#endif // IOS
switch ( command ) {
case GAME_INIT:
G_InitGame( arg0, arg1, arg2 );
return 0;
case GAME_SHUTDOWN:
G_ShutdownGame( arg0 );
return 0;
case GAME_CLIENT_CONNECT:
return (int)ClientConnect( arg0, arg1, arg2 );
case GAME_CLIENT_THINK:
ClientThink( arg0 );
return 0;
case GAME_CLIENT_USERINFO_CHANGED:
ClientUserinfoChanged( arg0 );
return 0;
case GAME_CLIENT_DISCONNECT:
ClientDisconnect( arg0 );
return 0;
case GAME_CLIENT_BEGIN:
ClientBegin( arg0 );
return 0;
case GAME_CLIENT_COMMAND:
ClientCommand( arg0 );
return 0;
case GAME_RUN_FRAME:
G_RunFrame( arg0 );
return 0;
case GAME_CONSOLE_COMMAND:
return ConsoleCommand();
case BOTAI_START_FRAME:
return BotAIStartFrame( arg0 );
}
return -1;
}
void QDECL G_Printf( const char *fmt, ... ) {
va_list argptr;
char text[1024];
va_start (argptr, fmt);
vsprintf (text, fmt, argptr);
va_end (argptr);
trap_Printf( text );
}
示例7: Info_SetValueForKey
//----(SA) modified this for head separation
gentity_t *AICast_AddCastToGame( gentity_t *ent, char *castname, char *model, char *head, char *sex, char *color, char *handicap )
{
int clientNum;
gentity_t *bot;
char userinfo[MAX_INFO_STRING];
usercmd_t cmd;
// create the bot's userinfo
userinfo[0] = '\0';
Info_SetValueForKey( userinfo, "name", castname );
Info_SetValueForKey( userinfo, "rate", "25000" );
Info_SetValueForKey( userinfo, "snaps", "20" );
Info_SetValueForKey( userinfo, "handicap", handicap );
Info_SetValueForKey( userinfo, "model", model );
Info_SetValueForKey( userinfo, "head", head );
Info_SetValueForKey( userinfo, "color", color );
// have the server allocate a client slot
clientNum = trap_BotAllocateClient();
if ( clientNum == -1 ) {
G_Printf( S_COLOR_RED "BotAllocateClient failed\n" );
return NULL;
}
bot = &g_entities[ clientNum ];
bot->r.svFlags |= SVF_BOT;
bot->r.svFlags |= SVF_CASTAI; // flag it for special Cast AI behaviour
// register the userinfo
trap_SetUserinfo( bot->s.number, userinfo );
// have it connect to the game as a normal client
//----(SA) ClientConnect requires a third 'isbot' parameter. setting to qfalse and noting
ClientConnect( bot->s.number, qtrue, qfalse );
//----(SA) end
// copy the origin/angles across
VectorCopy( ent->s.origin, bot->s.origin );
VectorCopy( ent->s.angles, bot->s.angles );
memset( &cmd, 0, sizeof( cmd ) );
ClientBegin( bot->s.number );
// set up the ai
AICast_SetupClient( bot->s.number );
return bot;
}
示例8: SocketConnect
void SocketConnect(char *argv[])
{
nPort = atoi(argv[1]);
nSocketDesc = socket(AF_INET,SOCK_STREAM,0);
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = INADDR_ANY;
serv.sin_port = htons(nPort);
bind(nSocketDesc,(struct sockaddr *)&serv,sizeof(serv));
listen(nSocketDesc,5);
printf("\n===========================\n");
printf("Waiting for connection\n");
printf("===========================\n\n");
ClientConnect();
close(nSocketDesc);
}
示例9: while
void ServerNetwork::newConnection() {
while (server->hasPendingConnections()) {
QTcpSocket *socket = server->nextPendingConnection();
s32 clientId = clientManager->AddClient(socket);
emit ClientConnect(clientId);
connect(socket, SIGNAL(readyRead()), SLOT(readyRead()));
connect(socket, SIGNAL(disconnected()), SLOT(disconnected()));
QByteArray *buffer = new QByteArray();
buffers.insert(socket, buffer);
qDebug().nospace() << "Connected: Instrument #" << clientId << " at " << qPrintable(socket->peerAddress().toString()) << ":" << socket->peerPort();
}
}
示例10: ACESP_SpawnBot
///////////////////////////////////////////////////////////////////////
// Spawn the bot
///////////////////////////////////////////////////////////////////////
void ACESP_SpawnBot (char *team, char *name, char *skin, char *userinfo)
{
edict_t *bot;
bot = ACESP_FindFreeClient ();
if (!bot)
{
safe_bprintf (PRINT_MEDIUM, "Server is full, increase Maxclients.\n");
return;
}
bot->yaw_speed = 100; // yaw speed
bot->inuse = true;
bot->is_bot = true;
// To allow bots to respawn
if(userinfo == NULL)
ACESP_SetName(bot, name, skin, team);
else
ClientConnect (bot, userinfo);
G_InitEdict (bot);
InitClientResp (bot->client);
// locate ent at a spawn point
/*if(ctf->value)
{
if (team != NULL && strcmp(team,"red")==0)
ACESP_PutClientInServer (bot,false, CTF_TEAM1);
else
ACESP_PutClientInServer (bot,false, CTF_TEAM2);
}
else*/
ACESP_PutClientInServer (bot,false,0);
// make sure all view stuff is valid
ClientEndServerFrame (bot);
ACEIT_PlayerAdded (bot); // let the world know we added another
ACEAI_PickLongRangeGoal(bot); // pick a new goal
}
示例11: while
void ServerSystem::Update( double DeltaTime )
{
PerfTimer.Log( "server update started" );
ENetEvent event;
while( enet_host_service ( mServer, & event, 0 ) > 0 )
{
//PerfTimer.Log("server enter");
switch ( event.type )
{
case ENET_EVENT_TYPE_CONNECT:
ClientConnect( event );
break;
case ENET_EVENT_TYPE_RECEIVE:
Receive( event );
break;
case ENET_EVENT_TYPE_DISCONNECT:
ClientDisconnect( event );
break;
}
}
PerfTimer.Log( "server receive ended" );
MessageList& messages = mMessageHolder.GetOutgoingMessages();
if ( messages.mMessages.size() > 0 )
{
std::ostringstream oss;
eos::portable_oarchive oa( oss );
oa& messages;
std::string astr( oss.str() );
// L1("server sends - %s:\n",astr.c_str());
ENetPacket* packet = enet_packet_create ( astr.c_str(),
astr.size(),
ENET_PACKET_FLAG_RELIABLE );
mSentMessagesSize += packet->dataLength * mClients.size();
enet_host_broadcast( mServer, 0, packet );
enet_host_flush( mServer );
mMessageHolder.ClearOutgoingMessages();
}
PerfTimer.Log( "server update ended" );
}
示例12: NetlibSslConnect
SslHandle* NetlibSslConnect(SOCKET s, const char* host, int verify)
{
SslHandle *ssl = (SslHandle*)mir_calloc(sizeof(SslHandle));
ssl->s = s;
SecInvalidateHandle(&ssl->hContext);
DWORD dwFlags = 0;
if (!host || inet_addr(host) != INADDR_NONE)
dwFlags |= 0x00001000;
bool res = SSL_library_init();
if (res) res = ClientConnect(ssl, host);
if (res && verify) res = VerifyCertificate(ssl, host, dwFlags);
if (!res) {
NetlibSslFree(ssl);
ssl = NULL;
}
return ssl;
}
示例13: vmMain
/*
================
vmMain
This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
switch ( command ) {
case GAME_INIT:
G_InitGame( arg0, arg1, arg2 );
return 0;
case GAME_SHUTDOWN:
G_ShutdownGame( arg0 );
return 0;
case GAME_CLIENT_CONNECT:
return (intptr_t)ClientConnect( arg0, arg1, arg2 );
case GAME_CLIENT_THINK:
ClientThink( arg0 );
return 0;
case GAME_CLIENT_USERINFO_CHANGED:
ClientUserinfoChanged( arg0 );
return 0;
case GAME_CLIENT_DISCONNECT:
ClientDisconnect( arg0 );
return 0;
case GAME_CLIENT_BEGIN:
ClientBegin( arg0 );
return 0;
case GAME_CLIENT_COMMAND:
ClientCommand( arg0 );
return 0;
case GAME_RUN_FRAME:
G_RunFrame( arg0 );
return 0;
case GAME_CONSOLE_COMMAND:
return ConsoleCommand();
case BOTAI_START_FRAME:
return BotAIStartFrame( arg0 );
}
return -1;
}
示例14: G_AddBot
//.........这里部分代码省略.........
Info_SetValueForKey( userinfo, "pWeapon", va("%i", playerWeapon) );
}*/
// END Mad Doc - TDF
key = "wolfbot";
if (!Q_stricmp( (char *)name, key )) {
// read the botnames file, and pick a name that doesnt exist
fileHandle_t f;
int len, i, j, k;
qboolean setname = qfalse;
char botnames[8192], *pbotnames, *listbotnames[MAX_BOTNAMES], *token, *oldpbotnames;
int lengthbotnames[MAX_BOTNAMES];
len = trap_FS_FOpenFile( "botfiles/botnames.txt", &f, FS_READ );
if (len >= 0) {
if (len > sizeof(botnames)) {
G_Error( "botfiles/botnames.txt is too big (max = %i)", (int)sizeof(botnames) );
}
memset( botnames, 0, sizeof(botnames) );
trap_FS_Read( botnames, len, f );
pbotnames = botnames;
// read them in
i = 0;
oldpbotnames = pbotnames;
while ((token = COM_Parse( &pbotnames ))) {
if (!token[0]) break;
listbotnames[i] = strstr( oldpbotnames, token );
lengthbotnames[i] = strlen(token);
listbotnames[i][lengthbotnames[i]] = 0;
oldpbotnames = pbotnames;
if (++i == MAX_BOTNAMES) break;
}
//
if (i > 2) {
j = rand() % (i-1); // start at a random spot inthe list
for( k = j + 1; k != j; k++ ) {
if( k == i ) {
k = -1; // gets increased on next loop
continue;
}
if (ClientFromName( listbotnames[k] ) == -1) {
// found an unused name
Info_SetValueForKey( userinfo, "name", listbotnames[k] );
setname = qtrue;
break;
}
}
}
//
trap_FS_FCloseFile( f );
}
if (!setname) {
Info_SetValueForKey( userinfo, "name", va("wolfbot_%i", clientNum+1) );
}
} else {
Info_SetValueForKey( userinfo, "name", name );
}
// if a character was specified, put the index of that character filename in the CS_CHARACTERS table in the userinfo
if( characerIndex != -1 ) {
Info_SetValueForKey( userinfo, "ch", va( "%i", characerIndex ) );
}
// if a rank was specified, use that
/* if (rank != -1) {
Info_SetValueForKey(userinfo, "rank", va("%i", rank));
}*/
// END Mad Doc - TDF
bot = &g_entities[ clientNum ];
bot->r.svFlags |= SVF_BOT;
if( pow ) {
bot->r.svFlags |= SVF_POW;
}
bot->inuse = qtrue;
bot->aiName = bot->client->pers.netname;
// register the userinfo
trap_SetUserinfo( clientNum, userinfo );
// have it connect to the game as a normal client
if ((s = ClientConnect( clientNum, qtrue, qtrue ))) {
G_Printf( S_COLOR_RED "Unable to add bot: %s\n", s );
return;
}
SetTeam( bot, (char *)team, qtrue, -1, -1, qfalse );
/* if( skills ) {
int i;
for( i = 0; i < SK_NUM_SKILLS; i++ ) {
bot->client->sess.skill[i] = skills[i];
}
}*/
return;
}
示例15: G_AddBot
//.........这里部分代码省略.........
if ( skill >= 1 && skill < 2 ) {
Info_SetValueForKey( userinfo, "handicap", "50" );
}
else if ( skill >= 2 && skill < 3 ) {
Info_SetValueForKey( userinfo, "handicap", "70" );
}
else if ( skill >= 3 && skill < 4 ) {
Info_SetValueForKey( userinfo, "handicap", "90" );
}
key = "model";
model = Info_ValueForKey( botinfo, key );
if ( !*model ) {
model = "sarge/default";
}
Info_SetValueForKey( userinfo, key, model );
key = "team_model";
Info_SetValueForKey( userinfo, key, model );
key = "headmodel";
headmodel = Info_ValueForKey( botinfo, key );
if ( !*headmodel ) {
headmodel = model;
}
Info_SetValueForKey( userinfo, key, headmodel );
key = "team_headmodel";
Info_SetValueForKey( userinfo, key, headmodel );
key = "gender";
s = Info_ValueForKey( botinfo, key );
if ( !*s ) {
s = "male";
}
Info_SetValueForKey( userinfo, "sex", s );
key = "color1";
s = Info_ValueForKey( botinfo, key );
if ( !*s ) {
s = "4";
}
Info_SetValueForKey( userinfo, key, s );
key = "color2";
s = Info_ValueForKey( botinfo, key );
if ( !*s ) {
s = "5";
}
Info_SetValueForKey( userinfo, key, s );
s = Info_ValueForKey(botinfo, "aifile");
if (!*s ) {
trap_Printf( S_COLOR_RED "Error: bot has no aifile specified\n" );
return;
}
// have the server allocate a client slot
clientNum = trap_BotAllocateClient();
if ( clientNum == -1 ) {
G_Printf( S_COLOR_RED "Unable to add bot. All player slots are in use.\n" );
G_Printf( S_COLOR_RED "Start server with more 'open' slots (or check setting of sv_maxclients cvar).\n" );
return;
}
// initialize the bot settings
if( !team || !*team ) {
if( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if( PickTeam(clientNum) == TEAM_RED) {
team = "red";
}
else {
team = "blue";
}
}
else {
team = "red";
}
}
Info_SetValueForKey( userinfo, "characterfile", Info_ValueForKey( botinfo, "aifile" ) );
Info_SetValueForKey( userinfo, "skill", va( "%5.2f", skill ) );
Info_SetValueForKey( userinfo, "team", team );
bot = &g_entities[ clientNum ];
bot->r.svFlags |= SVF_BOT;
bot->inuse = qtrue;
// register the userinfo
trap_SetUserinfo( clientNum, userinfo );
// have it connect to the game as a normal client
if ( ClientConnect( clientNum, qtrue, qtrue ) ) {
return;
}
if( delay == 0 ) {
ClientBegin( clientNum );
return;
}
AddBotToSpawnQueue( clientNum, delay );
}