Ezeer / JomTobo

Jomtobo
0 stars 0 forks source link

bypass the server for ninjam sessions #7

Open jonjamcam opened 8 years ago

jonjamcam commented 8 years ago

I think you made a great point with this, Ezee. Ninjam sessions do not need this "server" architecture, but it will be necessary for other features like real time rooms.

We need to remove it from the start of the application and keep it for specific purposes, but that do not affect the overall functioning.

Ezeer commented 8 years ago

" We need to remove it from the start of the application and keep it for specific purposes, but that do not affect the overall functioning. "

ok , let's work on that . ^^

jonjamcam commented 8 years ago

"will the architect like this idea?" lol

https://www.youtube.com/watch?v=ZKpFFD7aX3c

jonjamcam commented 8 years ago

I tried to isolate the loginservice.cpp without success. It's very much integrated into the whole application functioning. Any idea on how to run jomtobo "offline"?

I noticed too that there's line 18 that points to a local server

//const QString LoginService::SERVER = "http://localhost:8080/vs";

Maybe a faster solution? MAke the server local?

Ezeer commented 8 years ago

At the immediate no , but if i work on it , yes .

Ezeer commented 8 years ago

ok , i had a look , the entry point could be : https://github.com/Ezeer/JomTobo/blob/master/Client/src/MainController.cpp#L851

void MainController::tryConnectInNinjamServer(Login::RoomInfo ninjamRoom, QStringList channelsNames, QString password)

that funk takes "Login::RoomInfo" as parameter , so we must find a way to have a valid RoomInfo without the help of the server .

Ezeer commented 8 years ago

There is two rooms type : https://github.com/Ezeer/JomTobo/blob/master/Client/src/loginserver/LoginService.h#L38 enum class RoomTYPE{NINJAM, REALTIME};

You see that we will need the server for realtime thus .

jonjamcam commented 8 years ago

ok I see it. It is designed like this. To separate ninjam will be a mess....

Ezeer commented 8 years ago

No , that could be simple , the difficulty is to code in the client the server part that solves the connections ( find the ninjam servers , retrieve rooms infos ) .

Ezeer commented 8 years ago

these are the server's java source to retrieve ninjam infos : https://github.com/Ezeer/JomTobo/tree/master/Server/src/java/jamtaba/ninjam/public_servers

i need to translate that in c++ if i include them in the client , or php or python if i use a new type of server .with jomtobo .

jonjamcam commented 8 years ago

Remember that jamtaba is based on wahjam. Maybe here's the answer:

https://github.com/wahjam/wahjam

I'm too newbie to understand what is what in the codde....but for you it may be Ezee

Ezeer commented 8 years ago

that's cool Jon , your idea to use wahjam is a good shortcut , there is already Qt5 server code there : https://github.com/wahjam/wahjam/tree/master/server

i can try to use some of these files to bypass the server by implementing the client .

jonjamcam commented 8 years ago

good! As you can see Wahjam connects to ninjam without the need for this special server architecture

-

Ezeer commented 8 years ago

eh eh ! lol ... yeah , i just found the files needed to get the ninjam servers stuff : https://github.com/wahjam/wahjam/blob/master/qtclient/NINJAMServerBrowser.h

that should work ... ^^

jonjamcam commented 8 years ago

You da man!

https://www.youtube.com/watch?v=almbllyL7xk

Ezeer commented 8 years ago

" It's clear why the struggle was so painful Metamorphosis, this is what I changed to and God, I'm so thankful " Read more at http://www.songlyrics.com/nas/you-re-da-man-lyrics/#ULlPVf7c3VqpOGy0.99

;)

Ezeer commented 8 years ago

lol , the files i want to use were written by tea .... oh lol ! Copyright (C) 2012 Ikkei Shimomura (tea) Ikkei.Shimomura@gmail.com Copyright (C) 2012 Stefan Hajnoczi stefanha@gmail.com

ok ; i created a local branch " serverLess " , i'll push it if i have success on the incoming dayz ...

jonjamcam commented 8 years ago

full circle! lol

Ezeer commented 8 years ago

yeah , that's what i mean , and what the looper said with alpha and omega ... capture-1

jonjamcam commented 8 years ago

can I pull to see?

Ezeer commented 8 years ago

there is nothing to see yet , and the branch is local for now ( don't need to share my shit but my fruits ^^ ) . Be patient , the code is a long snake , i must get into it and it's a .... augmented_teleportation

kind of ... ^^

jonjamcam commented 8 years ago

aahha right.....

Ezeer commented 8 years ago

It's a lot of energy acquired by concentration to moove from A to O , you must know bcdefg etc ... " If you don't know where you go , why you run ? " lol

jonjamcam commented 8 years ago

of course.

Ezeer commented 8 years ago

O being the result of A on himself ( tip : A is a tool to draw a circle .... ) , i need to find A first . And A is for me :

void MainWindow::initializeLoginService(){
Login::LoginService* loginService = this->mainController->getLoginService();
connect( loginService, SIGNAL(roomsListAvailable(QList<Login::RoomInfo>)), this, SLOT(on_roomsListAvailable(QList<Login::RoomInfo>)));
connect( loginService, SIGNAL(incompatibilityWithServerDetected()), this, SLOT(on_incompatibilityWithServerDetected()));
connect( loginService, SIGNAL(newVersionAvailableForDownload()), this, SLOT(on_newVersionAvailableForDownload()));
connect( loginService, SIGNAL(errorWhenConnectingToServer(QString)), this, SLOT(on_errorConnectingToServer(QString)));

}

i already bypassed two of them to allow jomtobo to connect to the server , now i need to work on :

 connect( loginService, SIGNAL(roomsListAvailable(QList<Login::RoomInfo>)), this, SLOT(on_roomsListAvailable(QList<Login::RoomInfo>)));

to behave as if we used the server , to still have the rooms displayed ...

Ezeer commented 8 years ago

The following code occurs at launch time , just before the busydialog disappear and the rooms get filled :

void MainWindow::on_roomsListAvailable(QList<Login::RoomInfo> publicRooms)
{
hideBusyDialog();

refreshPublicRoomsList(publicRooms);

if(mainController->isPlayingInNinjamRoom())
{
    this->ninjamWindow->updateGeoLocations();
    //update country flag and country names. This is necessary because the call to webservice    used to get country codes and
    //country names is not synchronous. So, if country code and name are not cached we receive these data in some seconds.
}
}

i must find what trigger that event , and replace it with my code if it belongs to the server .

Ezeer commented 8 years ago

i got it ! https://github.com/Ezeer/JomTobo/blob/master/Client/src/loginserver/LoginService.cpp#L285 i change myself ( abracadabra ) in json , to being eat as parameter by : https://github.com/Ezeer/JomTobo/blob/master/Client/src/loginserver/LoginService.cpp#L256

that way i am in the matrix now ... and from there , i see every thing , like the heart of the service : https://github.com/Ezeer/JomTobo/blob/master/Client/src/loginserver/LoginService.cpp#L109

every digital heart beat , there is a request to the server asking for room info :

void LoginService::refreshTimerSlot(){
QUrlQuery query = HttpParamsFactory::createParametersToRefreshRoomsList();
pendingReply = sendCommandToServer(query);
if(pendingReply){
    connectNetworkReplySlots(pendingReply, LoginService::Command::REFRESH_ROOMS_LIST);
}

}

perhaps i only need to change the body of that funk , to get info directly from the ninjam server list and not by the jamtaba server .

jonjamcam commented 8 years ago

ahaha

https://www.youtube.com/watch?v=8m_qMDOQIcI&feature=youtu.be&t=175

Ezeer commented 8 years ago

very good exemple ! ^^

jonjamcam commented 8 years ago

I'm looking at wahjam code but can't get how it connects.

as far as I know the list used is this:

http://autosong.ninjam.com/server-list.php

EDIT: Found Elieser's explanation of how jamtaba connects (28 days ago):

"Guys, Jamtaba connect with jamtaba server and receive a list of public servers and connected musicians. Jamtaba server is requesting this list from 2 sources: http://autosong.ninjam.com/serverlist.php and http://ninbot.com/app/servers.php.

Why 2 sources to make a single list?

In the first link I have the maxUsers from every server. Jamtaba is using this info to disable the "Enter" button when a server is full. Some servers allow 6 users, other allow 8, etc. But in this first link we can't get the users IP, and without user IPs we can't translate the IP to a country name, and show a cool flag for the country. The Ninbot link is returning users IPs, but not the server maxUsers. To have all necessary info jamtaba server is merging this 2 sources.

A third and dirty solution is use this: http://autosong.ninjam.com/server-list.php

In this cockos official site is possible get maxUsers and users IPs, but we need get this infos directly in HTML code [scrapping], not very fun, but possible."

Ezeer commented 8 years ago

thks ! The connection dialog of wahjam is declared here : https://github.com/wahjam/wahjam/blob/master/qtclient/ConnectDialog.h

and the body of the funks are defined here :
https://github.com/wahjam/wahjam/blob/master/qtclient/ConnectDialog.cpp

but it's not the interesting part for me , the interesting is the core files written by tea . these 4 files i've downloaded and added in serverLess branch , and i will use certainly the php file you posted to get the servers infos.

jonjamcam commented 8 years ago

Is this the part of code where it connects to the list?

public: NINJAMServerBrowser(QNetworkAccessManager manager_, QWidget parent=0); QNetworkReply sendNetworkRequest(const QUrl &url); void parseServerList(QTextStream stream); };

Ezeer commented 8 years ago

yes .

jonjamcam commented 8 years ago

thx! now I start to see......

jonjamcam commented 8 years ago

So in short.

Jamtaba: connects to jamtaba server(http://jamtaba2.appspot.com/vs) and from here it requests the list from http://autosong.ninjam.com/serverlist.php and http://ninbot.com/app/servers.php.

wahjam: request the list directly from http://autosong.ninjam.com/serverlist.php

Ezeer commented 8 years ago

yeah , that is a good snapshot . But i must fullfill the needed Login::RoomInfo of jamtaba with the data retrieved by the tea's code , and i'm not sure that the format is the same . Not a problem , but i must check every detail ...

Ezeer commented 8 years ago

okay , i see that the subject interest you so much , i will push the branch with the new files on it so you could pull and see by yourself how i will make the changes . done here : https://github.com/Ezeer/JomTobo/tree/serverLess

jonjamcam commented 8 years ago

Yes. It's important for me. I understand that the magic of opensource projects is that the code is subject to query by anyone.

My four years of experience with ninjam have been always about freedom. Jamtaba made me question how free I am when using it since this happened, the "Jamtaba kicked me out" thread:

https://github.com/elieserdejesus/JamTaba/issues/124

So now I must understand what is going on behind the scenes, because I see this bottlenecks as going back, not forward.

But this is just my opinion.....

jonjamcam commented 8 years ago

So I have to use

"Git branch https://github.com/Ezeer/JomTobo/tree/serverLess"

and then "git pull"

Ezeer commented 8 years ago

No, the order is :

jonjamcam commented 8 years ago

Did 1st git checkout master and git status:

git branch2

now git checkout serverLess and then git pull?

Ezeer commented 8 years ago

ok , do : git pull ( will update your master ) then git checkout serverLess

jonjamcam commented 8 years ago

done.

git branch3

now testing

Ezeer commented 8 years ago

good job . i made no changes , just added the files in loginserver . I must let the idea diffuse his light on my mind , as tea on hot water ... lol

jonjamcam commented 8 years ago

Right........For me this thread's been an eye opener.......

jonjamcam commented 8 years ago

in two week's It's going to be 5 years I've been in ninjam!

Ezeer commented 8 years ago

bodybuilder

ah ah ah ah ...

jonjamcam commented 8 years ago

lol and I don't want this happening....

https://www.youtube.com/watch?v=Vpj6Yotdxtg&feature=youtu.be&t=86

Ezeer commented 8 years ago

oh woaw ! an other very good example ! ah ah ah .... ok , i take a break to reach my dream land where all started for me , and we'll continue that work tomorrow , k ? ^^

jonjamcam commented 8 years ago

thx, man..cya

jonjamcam commented 8 years ago

Ezee!!!! Made QT compile Jamtaba as STATIC!

can you test it plz? (remove .txt)

Jamtaba2.exe.txt

Jomtobo still doesn't do the trick, tho....