1 // nlib_driver.cpp :
\83R
\83\93\83\
\81[
\83\8b \83A
\83v
\83\8a\83P
\81[
\83V
\83\87\83\93\82Ì
\83G
\83\93\83g
\83\8a \83|
\83C
\83\93\83g
\82ð
\92è
\8b`
\82µ
\82Ü
\82·
\81B
6 #include <qwerty\windebuger.h>
8 #include <shareCookie\shareCookie.h>
9 #include <shareCookie\browserType.h>
10 #include <nlib\nlib.h>
11 #include <nlib\nlib_define.h>
15 //
\83\89\83C
\83u
\83\89\83\8a\83\8a\83\93\83N
16 #pragma comment(lib,"Wininet.lib")
17 #pragma comment(lib,"WinHttp.lib")
18 #pragma comment(lib,"Iepmapi.lib")
19 #pragma comment(lib,"ws2_32.lib")
20 #pragma comment(lib, "shell32.lib" )
21 #pragma comment(lib,"expat.lib")
22 #pragma comment(lib,"sqlite3.lib")
23 #pragma comment(lib,"sqliteManager.lib")
24 #pragma comment(lib,"shareCookie.lib")
25 #pragma comment(lib,"nlib.lib")
26 #pragma comment(lib,"winmm.lib")
27 #pragma comment(lib,"JSONParser.lib")
33 HINTERNET hInternet = WinHttpOpen(L"nicoliveTest",WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,(LPCWSTR)WINHTTP_NO_PROXY_NAME,(LPCWSTR)WINHTTP_NO_PROXY_BYPASS,0);
35 int nicoLive_setup(void) {
41 //WSAData
\82ð
\8f\89\8aú
\89»
42 while((err = WSAStartup(MAKEWORD(2,0),&wsaData)) == WSASYSNOTREADY){
52 if(err != ERROR_SUCCESS){
54 return NLIB_INITALIZE_FAILED_NETWORK;
56 InitializeNLIB(hInternet);
57 nl = NicoLiveStream_new();
58 nva = NicoVideoAuth_new();
59 NicoVideoAuth_getNicoVideoAuth(nva,BT_GOOGLE_CHROME);
60 return nl != NULL ? 0 : 1;
63 int nicoLive_teardown(void) {
64 NicoLiveStream_delete(&nl);
65 NicoVideoAuth_delete(&nva);
67 WinHttpCloseHandle(hInternet);
75 NLIB_RESULT callback(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2){
80 case NICOLIVE_EVENT_ERR_CONNECT:
82 errprint(TEXT("
\92Ê
\90M
\83G
\83\89\81[
\94
\90¶"));
87 case NICOLIVE_EVENT_RECEVE_CONNECTRESULT:
89 println(TEXT("receveStart::last_res[%s],thread[%s],ticket[%s],server_time[%s]"),((NicoLiveThreadComment_P)param1)->last_res,((NicoLiveThreadComment_P)param1)->thread,((NicoLiveThreadComment_P)param1)->ticket,((NicoLiveThreadComment_P)param1)->server_time);
93 case NICOLIVE_EVENT_RECEVE_CHAT:
97 NicoLiveChat_P chatP = (NicoLiveChat_P)param1;
98 int index = chatP->mailCount;
99 println(TEXT("recevechat::no[%s],locale[%s],vpos[%s],date[%s],premium[%s],anonymity[%s],thread[%s],user_id[%s],name[%s]"),chatP->no,chatP->locale,chatP->vpos,chatP->date,chatP->premium,chatP->anonymity,chatP->thread,chatP->user_id,chatP->name);
105 println(TEXT("mail(%d)[%s]"),i,chatP->mail[i]);
109 println(TEXT("chatBody::%s"),chatP->chatBuf);
114 case NICOLIVE_EVENT_RECEVE_CHATSETTLE:
118 println(TEXT("recevechatCount::no[%d],count[%d]"),param1,param2);
123 case NICOLIVE_EVENT_RECEVE_CHATSENDRESULT:
126 NicoLiveSendResultComment_P nls = (NicoLiveSendResultComment_P)param1;
128 println(TEXT("sendresult::no[%s],status[%s],thread[%s]"),nls->no,nls->status,nls->thread);
134 case NICOLIVE_EVENT_SEND_HEARTBEAT:
138 NicoLiveHeartBeat_P hbp = (NicoLiveHeartBeat_P)param1;
140 println(TEXT("heartbeat::time[%llu],watchCount[%d],commentCount[%d],is_restrict[%s],ticket[%s]"),hbp->time,hbp->watchCount,hbp->commentCount,hbp->is_restrict,hbp->ticket);
141 //println(TEXT("heartbeat::watchCount[%d],commentCount[%d],is_restrict[%s],ticket[%s]"),hbp->watchCount,hbp->commentCount,hbp->is_restrict,hbp->ticket);
155 NLIB_RESULT myListCallBack(LPVOID option,NicoMyListItem_P pVideo){
157 // dumpln(TEXT("video_id:%s"),pVideo->itemData.video_id);
164 static NLIB_RESULT myListGroupCallBack(LPVOID option,NicoMyList_P pMyList){
167 // wcscpy(buf,pMyList->id);
168 dumpln(TEXT("id:%s"),buf);
169 rslt = NicoMyList_getMyList(nva,buf,myListCallBack,NULL);
176 void nicoLive_connect(void) {
179 NicoLiveStrream_setResFrom(nl,1000);
180 //NicoLiveStream_setHeartBeatMsec(nl,5000);
181 //NicoLiveStream_setKeapALiveMsec(nl,5000);
182 //NicoLiveStream_setKeapALiveFlag(nl,FALSE);
185 WCHAR housoubuf[LENGTH_1024];
186 std::wcin.getline(housoubuf,sizeof(housoubuf) / sizeof(housoubuf[0]));
192 for(int index = 0;index < 5;index++){
193 check(NicoLiveStream_connect(nl,nva,housoubuf,callback,NULL) == NLIB_ERR_OK,TEXT("
\90Ú
\91±
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½"));
194 // NicoLiveStream_queryStreamInfo(nl);
195 std::wcin.getline(buf,sizeof(buf) / sizeof(buf[0]));
197 LPWSTR mail = L"184";
198 LPWSTR exname = L"name";
199 LPWSTR exvalue = L"qwerty";
201 LPCWSTR mails[2] = {mail,NULL};
202 LPCWSTR extends[3] = {exname,exvalue,NULL};
205 while(wcslen(buf) > 0){
207 NicoLiveStream_sendChat(nl,buf,mails,NULL);
208 std::wcin.getline(buf,sizeof(buf) / sizeof(buf[0]));
210 NicoLiveStream_disConnect(nl);
213 check(_heapchk() == _HEAPOK,TEXT("
\83q
\81[
\83v
\83G
\83\89\81[
\82Å
\82·"));
225 void nicoLive_mylist(void) {
229 //check(NicoMyList_getDefList(nva,myListCallBack,NULL) == NLIB_ERR_OK,TEXT("
\82Æ
\82è
\82 \82¦
\82¸
\83}
\83C
\83\8a\83X
\83g
\8eæ
\93¾
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½"));
230 //check(NicoMyList_getMyListGroup(nva,myListGroupCallBack,NULL) == NLIB_ERR_OK,TEXT("
\83}
\83C
\83\8a\83X
\83g
\83O
\83\8b\81[
\83v
\93o
\98^
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½"));
231 //check(NicoMyList_addItem(L"sm16046365") == NLIB_ERR_OK,TEXT("
\83}
\83C
\83\8a\83X
\83g
\93o
\98^
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½!"));
232 //check(_heapchk() == _HEAPOK,TEXT("heap
\83G
\83\89\81[
\82Å
\82·"));
233 dumpln(TEXT("heapchk:%d"),_heapchk());
241 int _tmain(int argc, _TCHAR* argv[])
247 for(int index = 0; index <= NLIB_ERR_NOT_LIVECONNECT;index++){
249 idumpln(TEXT("errmessage:%s"),NLIB_GetErrorMessage(index));