NLIB_RESULT NicoLiveStream_sendOwnerChat(NicoLiveStream_P self,LPCTSTR chatbuf,LPCTSTR *mail,LPCTSTR *extends){
+ static const LPCTSTR OWNERCHAT_REQUEST = TEXT("api/broadcast/%s?body=%s%s&token=%s%s");
NLIB_RESULT rslt = NLIB_ERR_CODE_NOTSET;
LPVOID buffer = malloc(LENGTH_65536 * sizeof(TCHAR));
LPTSTR requestBuffer = (LPTSTR)buffer;
const UINT_PTR buflen = LENGTH_8192;
- LPSTR recvBuffer = (LPSTR)&requestBuffer[buflen];
+ LPTSTR mailBuf = (LPTSTR)&requestBuffer[buflen];
+ LPTSTR extendsBuf = (LPTSTR)&mailBuf[buflen];
+ LPSTR recvBuffer = (LPSTR)&extendsBuf[buflen];
DWORD readSize;
DWORD statusCode;
DWORD statusCodeSize = sizeof(statusCode);
- HINTERNET hRequest = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",requestBuffer,L"1.1",(LPCTSTR)WINHTTP_NO_REFERER,(LPCTSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
+ UINT_PTR reqLength = _tcslen(chatbuf);
+ HINTERNET hRequest = NULL;
+ for(LPCTSTR *mailStart = mail;mailStart[0] != NULL;++mailStart){
+
+ reqLength += _tcslen(mailStart[0]);
+
+ }
+
+ LPCTSTR *extendsArrayIndex = extends;
+ for(;extendsArrayIndex[0] != NULL;extendsArrayIndex+=2){
+
+ reqLength += _tcslen(extendsArrayIndex[0]);
+ reqLength += _tcslen(extendsArrayIndex[1]);
+ }
+
+ if(reqLength > buflen / 2){
+
+ goto buffererr;
+
+ }
+ LPTSTR mailIndexPtr = mailBuf;
+ if(mail[0] == NULL){
+ _tcscpy(mailIndexPtr,TEXT(""));
+
+ } else {
+
+ _tcscpy(mailIndexPtr,TEXT("&mail="));
+ mailIndexPtr += _tcslen(mailIndexPtr);
+
+ }
+ for(LPCTSTR *mailArrayIndex = mail;mailArrayIndex[0] != NULL;++mailArrayIndex){
+
+ _tcscpy(mailIndexPtr,mailArrayIndex[0]);
+ mailIndexPtr += _tcslen(mailIndexPtr);
+
+ if(mailArrayIndex[1] != NULL){
+
+ mailIndexPtr[0] = TEXT(' ');
+ ++mailIndexPtr;
+
+ }
+
+ }
+
+ LPTSTR extendsIndexPtr = extendsBuf;
+ _tcscpy(extendsIndexPtr,TEXT(""));
+ for(LPCTSTR *extendsArrayIndex2 = extends;extendsArrayIndex2[0] != NULL;extendsArrayIndex2+=2){
+
+
+ extendsIndexPtr[0] = TEXT('&');
+ ++extendsIndexPtr;
+
+
+ _tcscpy(extendsIndexPtr,extendsArrayIndex2[0]);
+ extendsIndexPtr += _tcslen(extendsIndexPtr);
+ extendsIndexPtr[0] = TEXT('=');
+ ++extendsIndexPtr;
+ _tcscpy(extendsIndexPtr,extendsArrayIndex2[1]);
+ extendsIndexPtr += _tcslen(extendsIndexPtr);
+
+
+ }
+
+ _stprintf(requestBuffer,OWNERCHAT_REQUEST,self->playerStatus.stream.id,chatbuf,mailBuf,self->publishStatus.token,extendsBuf);
+
+ ::EnterCriticalSection(&self->sessionManager.cs);
+ hRequest = WinHttpOpenRequest(hWatchLiveNicoConnect,L"GET",requestBuffer,L"1.1",(LPCTSTR)WINHTTP_NO_REFERER,(LPCTSTR*)WINHTTP_DEFAULT_ACCEPT_TYPES,0);
if(WinHttpSendRequest(hRequest,self->userSession,-1,WINHTTP_NO_REQUEST_DATA,0,0,0) == FALSE){
end:
free(buffer);
WinHttpCloseHandle(hRequest);
-
+ ::LeaveCriticalSection(&self->sessionManager.cs);
return rslt;
rslt = NLIB_FAILED_CONNECT;
goto end;
+
+
+buffererr:
+
+ rslt = NLIB_ERR_BUFFER_TOOLITTLE;
+ goto end;
}
return;
}
-static VOID EnterChatBox(LPVOID userData){
+VOID CSubChatEdit::EnterChatBox(LPVOID userData){
((CSubChatEdit*)userData)->SetReadOnly(TRUE);
- Sleep(3000);
+ if(((CSubChatEdit*)userData)->self.nicoLiveStream.IsOwner()){
+
+ Sleep(1500);
+
+ }else {
+ Sleep(3000);
+ }
((CSubChatEdit*)userData)->AgreeEnter();
_endthread();
BOOL CCommentWriteWindow::SendChat(){
- _beginthread(EnterChatBox,0,&this->commentSubEdit);
+ _beginthread(CSubChatEdit::EnterChatBox,0,&this->commentSubEdit);
CCommentMaker commentMaker;
std::vector<TCHAR> chat(commentSubEdit.GetWindowTextLengthW() + 1);
BOOL rslt = FALSE;
- NLIB_RESULT code = nicoLiveStream.SendChat(commentMaker);
+ NLIB_RESULT code = NLIB_ERR_CODE_NOTSET;
+
+ if(nicoLiveStream.IsOwner() ==TRUE && this->ownerModeButton.GetCheck() == BST_CHECKED){
+
+ code = nicoLiveStream.SendOwnerChat(commentMaker);
+
+ } else {
+
+ code = nicoLiveStream.SendChat(commentMaker);
+
+ }
switch(code){
goto end;
case NLIB_ERR_NOT_LIVECONNECT:
-
+ case NLIB_FAILED_CONNECT:
::MessageBox(*this,NLIB_GetErrorMessage(code),TEXT("\83R\83\81\83\93\83g\8f\91\82«\8d\9e\82Ý\83G\83\89\81["),MB_ICONERROR | MB_OK);
commentSubEdit.AgreeEnter();
break;
+
+
+
+
default:
UnexpectedErrorMessageShow(TEXT("\83R\83\81\83\93\83g\8f\91\82«\8d\9e\82Ý\92\86\82É"),NLIB_GetErrorMessage(code),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
commentSubEdit.AgreeEnter();