Added serverSocketChannel for game creation
This commit is contained in:
parent
546e341433
commit
48705f7e76
30 changed files with 1787 additions and 606 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package com.texttwist.client.pages;
|
||||
package com.texttwist.client;
|
||||
|
||||
import com.texttwist.client.ui.TTContainer;
|
||||
import com.texttwist.client.pages.AuthService;
|
||||
import com.texttwist.client.pages.Home;
|
||||
import com.texttwist.client.pages.SessionService;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
|
@ -10,7 +12,6 @@ import java.awt.*;
|
|||
*/
|
||||
public class App extends JFrame {
|
||||
|
||||
protected TTContainer root;
|
||||
public static AuthService authService;
|
||||
public static SessionService sessionService;
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
package com.texttwist.client;
|
||||
import com.texttwist.client.pages.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import com.texttwist.client.constants.Config;
|
||||
import interfaces.ITTAuth;
|
||||
import models.TTResponse;
|
||||
import interfaces.IAuth;
|
||||
import models.Response;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Created by loke on 17/06/2017.
|
||||
|
|
@ -21,18 +19,18 @@ public class AuthService {
|
|||
public AuthService(){
|
||||
}
|
||||
|
||||
public TTResponse login(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
ITTAuth auth = (ITTAuth) Naming.lookup(baseUrl);
|
||||
public Response login(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
IAuth auth = (IAuth) Naming.lookup(baseUrl);
|
||||
return auth.login(userName, password);
|
||||
}
|
||||
|
||||
public TTResponse register(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
ITTAuth auth = (ITTAuth) Naming.lookup(baseUrl);
|
||||
public Response register(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
IAuth auth = (IAuth) Naming.lookup(baseUrl);
|
||||
return auth.register(userName, password);
|
||||
}
|
||||
|
||||
public TTResponse logout(String userName, String token) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
ITTAuth auth = (ITTAuth) Naming.lookup(baseUrl);
|
||||
public Response logout(String userName, String token) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
IAuth auth = (IAuth) Naming.lookup(baseUrl);
|
||||
return auth.logout(userName, token);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.pages.*;
|
||||
import com.texttwist.client.ui.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
|
@ -125,7 +126,7 @@ public class Game extends Page {
|
|||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return new Menu(Page.window);
|
||||
return new com.texttwist.client.pages.Menu(Page.window);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.texttwist.client.pages;
|
|||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.*;
|
||||
import com.texttwist.client.ui.TTDialog;
|
||||
import models.TTResponse;
|
||||
import models.Response;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
|
@ -50,7 +50,7 @@ public class Home extends Page {
|
|||
@Override
|
||||
public Object call() throws Exception {
|
||||
//TODO CHIAMA API PER LOGIN E SE TUTTO OKEY MANDA A PAGINA DEL MENU
|
||||
TTResponse res = homeController.login(usernameField.getText(), String.valueOf(passwordField.getPassword()));
|
||||
Response res = homeController.login(usernameField.getText(), String.valueOf(passwordField.getPassword()));
|
||||
if (res.code == 200){
|
||||
//OK, go to next page and show popup
|
||||
return new Menu(window);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package com.texttwist.client.pages;
|
||||
import com.texttwist.client.constants.Config;
|
||||
import interfaces.ITTAuth;
|
||||
import models.TTResponse;
|
||||
import com.texttwist.client.App;
|
||||
import models.Response;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Created by loke on 15/06/2017.
|
||||
|
|
@ -18,10 +14,10 @@ public class HomeController {
|
|||
public HomeController(){
|
||||
}
|
||||
|
||||
public TTResponse login(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
TTResponse res = App.authService.login(userName,password);
|
||||
public Response login(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
Response res = App.authService.login(userName,password);
|
||||
if (res.code == 200){
|
||||
App.sessionService.create(userName, password);
|
||||
App.sessionService.create(userName, res.data.get("token").toString());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
package com.texttwist.client.pages;
|
||||
import com.texttwist.client.App;
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.*;
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ public class Menu extends Page{
|
|||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
menuController.logout("","");
|
||||
menuController.logout(App.sessionService.account.userName,App.sessionService.account.token);
|
||||
return new Home(Page.window);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import com.texttwist.client.constants.Config;
|
||||
import interfaces.ITTAuth;
|
||||
import models.TTResponse;
|
||||
import com.texttwist.client.App;
|
||||
import models.Response;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
|
|
@ -17,8 +15,8 @@ public class MenuController {
|
|||
public MenuController(){
|
||||
}
|
||||
|
||||
public TTResponse logout(String userName, String token) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
TTResponse res = App.authService.logout(userName,token);
|
||||
public Response logout(String userName, String token) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
Response res = App.authService.logout(userName,token);
|
||||
if (res.code == 200){
|
||||
App.sessionService.remove();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.texttwist.client.pages;
|
|||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.*;
|
||||
import models.TTResponse;
|
||||
import models.Response;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
|
@ -55,7 +55,7 @@ public class Register extends Page {
|
|||
@Override
|
||||
public Object call() throws Exception {
|
||||
//TODO CHIAMA API PER LOGIN E SE TUTTO OKEY MANDA A PAGINA DEL MENU
|
||||
TTResponse res = registerController.register(usernameField.getText(), String.valueOf(passwordField.getPassword()));
|
||||
Response res = registerController.register(usernameField.getText(), String.valueOf(passwordField.getPassword()));
|
||||
if (res.code == 200){
|
||||
return new TTDialog("success", res.message,
|
||||
new Callable() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import com.texttwist.client.constants.Config;
|
||||
import interfaces.ITTAuth;
|
||||
import models.TTResponse;
|
||||
import com.texttwist.client.App;
|
||||
import models.Response;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
|
|
@ -17,7 +15,7 @@ public class RegisterController {
|
|||
public RegisterController(){
|
||||
}
|
||||
|
||||
public TTResponse register(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
public Response register(String userName, String password) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
return App.authService.register(userName,password);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,17 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import interfaces.ITTAuth;
|
||||
import models.TTAccount;
|
||||
import models.TTResponse;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import models.Session;
|
||||
|
||||
/**
|
||||
* Created by loke on 17/06/2017.
|
||||
*/
|
||||
public class SessionService {
|
||||
|
||||
protected TTAccount account;
|
||||
|
||||
public Session account;
|
||||
public SessionService(){}
|
||||
|
||||
public void create(String userName, String token) {
|
||||
account = new TTAccount(userName, token);
|
||||
account = new Session(userName, token);
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue