void ProfilerSocket::SendProfilerMessage( const string& strMessage ) { _szOperation = "SendProfilerMessage"; SendNetworkMessage( PROFILER_MESSAGE ); SendString( strMessage ); }
void ProfilerSocket::SendThreadCreate( ThreadID tid ) { _szOperation = "SendThreadCreate"; SendNetworkMessage( THREAD_CREATE ); SendThreadID( tid ); }
void ProfilerSocket::SendStartFunctionData( ThreadID tid ) { _szOperation = "SendStartFunctionData"; SendNetworkMessage( FUNCTION_DATA ); SendThreadID( tid ); }
void ProfilerSocket::SendAppDomainCreate( AppDomainID aid ) { _szOperation = "SendAppDomainCreate"; SendNetworkMessage( APPDOMAIN_CREATE ); SendAppDomainID( aid ); }
void ProfilerSocket::SendShutdown() { if ( !_bInitialized ) return; _szOperation = "SendShutdown"; SendNetworkMessage( SHUTDOWN ); }
void ProfilerSocket::SendThreadEnd( ThreadID tid, UINT64 llThreadStartTime, UINT64 llThreadEndTime ) { _szOperation = "SendThreadEnd"; SendNetworkMessage( THREAD_END ); SendThreadID( tid ); SendUINT64( llThreadStartTime ); SendUINT64( llThreadEndTime ); }
void ProfilerSocket::SendInitialize() { _szOperation = "SendInitialize"; SendNetworkMessage( INITIALIZE ); SendUINT32( NETWORK_PROTOCOL_VERSION ); BYTE b; if ( ReadByte( b ) == 0 ) { if ( b == 2 ) { b = 1; ::DebugBreak(); } if ( b == 1 ) { cout << "Successfully initialized profiler socket!" << endl; ReadByte( b ); _nApplicationID = b; cout << "Application ID = " << _nApplicationID << endl; SendUINT32( ::GetCurrentProcessId() ); int nArgs; LPWSTR* pstrCmdLine = ::CommandLineToArgvW( ::GetCommandLineW(), &nArgs ); SendUINT32( nArgs ); for ( int nArg = 0; nArg < nArgs; nArg++ ) { string strArg = CW2A( pstrCmdLine[ nArg ] ); SendString( strArg ); } ::GlobalFree( pstrCmdLine ); _bInitialized = true; } else { cout << "We weren't allowed to initialize!" << endl; _bInitialized = false; } } else { cout << "Could not initialize!" << endl; _bInitialized = false; } }
//UI Methods void NetworkChat(bool* opened) { ImGui::SetNextWindowSize(ImVec2(550, 275)); ImGui::SetNextWindowContentSize(ImVec2(550, 250)); if (!strcmp(input, "")) sceneManager->EnableInput(); else sceneManager->DisableInput(); if (!ImGui::Begin("Chat Log", opened)) { ImGui::End(); return; } ImGui::BeginChild("Log"); ImGui::TextUnformatted(logger.begin(), logger.end()); ImGui::SetScrollY(ImGui::GetScrollMaxY()); ImGui::EndChild(); ImGui::InputText("", input, 256); ImGui::SameLine(); if (ImGui::Button("Send")) { if (input[0] == '@') { char buffer[256]; if (sscanf(input, "@clear -%s\0", buffer)) { if (strcmp(buffer, "all")) logger.clear(); } if (sscanf(input, "@name -%s\0", buffer)) { ZeroMemory(name, 256); strcat(name, "["); strcat(name, buffer); strcat(name, "]"); logger.append("name Changed to : ");logger.append(name);logger.append("\n"); } } else { char buffer[256]; ZeroMemory(buffer, 256); strcat(buffer, name); strcat(buffer, input); strcat(buffer, "\n"); logger.append(buffer); SendNetworkMessage(buffer); } ZeroMemory(input, 256); } ImGui::End(); }
/**************************************************************************************************************** * Function: DSConnect * Desc: Attempts to connect to the DM Digital Sprite video server according to its connection protocol * Params: * h - Pointer to URLContext struct used to store all connection info associated with this connection * path - TODO: Need to confirm whether these params are actually needed * hoststr - * auth - Authentication credentials * Return: * 0 on success, non 0 on failure ****************************************************************************************************************/ static int DSConnect( URLContext *h, const char *path, const char *hoststr, const char *auth ) { NetworkMessage * sendMessage = NULL; NetworkMessage * recvMessage = NULL; int retVal = 0; int isConnecting = 1; char * encCredentials = NULL; ClientConnectMsg * connectMsg = NULL; int channelID = -2; int streamType = 0, res = 0, cam = 0; time_t from = 0, to = 0; int rate = 0; vcrMode playMode = VM_PLAY; char user[MAX_USER_ID_LENGTH]; char password[MAX_USER_ID_LENGTH]; /* Initialise the user and password fields */ memset( user, 0, sizeof(char) * MAX_USER_ID_LENGTH ); memset( password, 0, sizeof(char) * MAX_USER_ID_LENGTH ); /* Extract the username and password */ if( (retVal = GetUserAndPassword( auth, user, password )) == 0 ) { /* Crack the URI to get the control parameters */ retVal = CrackURI( path, &streamType, &res, &cam, &from, &to, &rate, &playMode ); } while( isConnecting && retVal == 0 ) { if( (sendMessage = CreateNetworkMessage( TCP_CLI_CONNECT, channelID )) == NULL ) { if( encCredentials != NULL ) av_free( encCredentials ); return AVERROR(ENOMEM); } /* Set up the connection request */ /* Set the message body up now */ connectMsg = (ClientConnectMsg *)sendMessage->body; connectMsg->udpPort = DS_DEFAULT_PORT; if( streamType == DS_PLAYBACK_MODE_PLAY ) connectMsg->connectType = IMG_PLAY; else connectMsg->connectType = IMG_LIVE; if( encCredentials != NULL ) { memcpy( connectMsg->userID, user, strlen(user) ); memcpy( connectMsg->accessKey, encCredentials, strlen(encCredentials) ); } /* Send the message to the server */ if( (retVal = SendNetworkMessage( h, sendMessage )) >= 0 ) { /* Receive the response */ if( (retVal = ReceiveNetworkMessage( h, &recvMessage )) >= 0 ) { switch( recvMessage->header.messageType ) { case TCP_SRV_CONNECT_REJECT: { /* We expect this first time */ /* Extract the info we need to encrypt */ SrvConnectRejectMsg * msg = (SrvConnectRejectMsg *)recvMessage->body; /* What was the reason for the failure? */ if( msg->reason == REJECT_AUTHENTIFICATION_REQUIRED ) { channelID = recvMessage->header.channelID; /* Encrypt the username / password */ if( strlen( user ) > 0 && strlen( password ) > 0 ) { if( (encCredentials = EncryptPasswordString( user, password, msg->timestamp, msg->macAddr, msg->appVersion )) == NULL ) retVal = AVERROR(ENOMEM); } else { /* If we haven't got a user and password string then we have to notify the client */ retVal = ADFFMPEG_DS_ERROR_AUTH_REQUIRED; } } else if( msg->reason == REJECT_AUTHENTIFICATION_INVALID ) { /* Supplied credentials are invalid */ retVal = ADFFMPEG_DS_ERROR_INVALID_CREDENTIALS; } else { /* Fail */ retVal = AVERROR(EIO); isConnecting = 0; } } break; case TCP_SRV_FEATURE_CONNECT_REPLY: case TCP_SRV_CONNECT_REPLY: { /* Great, we're connected - we just need to send a IMG_LIVE_REQUEST to the server to start the streaming */ NetworkMessage * imgRequestMsg = NULL; if( streamType == DS_PLAYBACK_MODE_LIVE ) { if( (imgRequestMsg = CreateNetworkMessage( TCP_CLI_IMG_LIVE_REQUEST, channelID )) ) { CliImgLiveRequestMsg * msgBody = (CliImgLiveRequestMsg *)imgRequestMsg->body; msgBody->cameraMask = cam; msgBody->resolution = res; } } else if( streamType == DS_PLAYBACK_MODE_PLAY ) { if( (imgRequestMsg = CreateNetworkMessage( TCP_CLI_IMG_PLAY_REQUEST, channelID )) ) { CliImgPlayRequestMsg * msgBody = (CliImgPlayRequestMsg *)imgRequestMsg->body; msgBody->cameraMask = cam; msgBody->fromTime = TimeTolong64( from ); msgBody->toTime = TimeTolong64( to ); msgBody->pace = rate; msgBody->mode = playMode; } } else retVal = AVERROR(EIO); if( retVal == 0 ) { /* Fire the request message off */ retVal = SendNetworkMessage( h, imgRequestMsg ); } isConnecting = 0; } break; /* Anything other than a connect reply is failure */ default: { retVal = -1; isConnecting = 0; } break; } } else isConnecting = 0; } else isConnecting = 0; /* We can release the messages now */ FreeNetworkMessage( &sendMessage ); FreeNetworkMessage( &recvMessage ); } return retVal; }