You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.0 KiB
118 lines
3.0 KiB
import java.util.ArrayList;
|
|
import java.util.function.BooleanSupplier;
|
|
|
|
/**
|
|
* Created by itsmy_000 on 13.08.2016.
|
|
*/
|
|
public class socketInfo {
|
|
public static ArrayList<String> ROLE, PROTOCOL, EVENT, TRACKID;
|
|
public static ArrayList<Integer> VKID, TIME, SOCKETID, PARTYID;
|
|
public static ArrayList<Boolean> ONLINE, httpAuth, protocolAuth;
|
|
public static ArrayList<client> CLIENT;
|
|
public static Integer sid;
|
|
|
|
|
|
public static void init(){
|
|
sid = 0;
|
|
VKID = new ArrayList<>();
|
|
TIME = new ArrayList<>();
|
|
ROLE = new ArrayList<>();
|
|
EVENT = new ArrayList<>();
|
|
CLIENT = new ArrayList<>();
|
|
PARTYID = new ArrayList<>();
|
|
TRACKID = new ArrayList<>();
|
|
PROTOCOL = new ArrayList<>();
|
|
SOCKETID = new ArrayList<>();
|
|
ONLINE = new ArrayList<>();
|
|
httpAuth = new ArrayList<>();
|
|
protocolAuth = new ArrayList<>();
|
|
}
|
|
|
|
public static void create(client c, Integer sid){
|
|
VKID.add(0);
|
|
TIME.add(0);
|
|
ROLE.add("");
|
|
EVENT.add("");
|
|
ONLINE.add(true);
|
|
CLIENT.add(c);
|
|
TRACKID.add("");
|
|
PROTOCOL.add("");
|
|
PARTYID.add(0);
|
|
SOCKETID.add(sid);
|
|
httpAuth.add(false);
|
|
protocolAuth.add(false);
|
|
}
|
|
|
|
public static void close(Integer sid){
|
|
int s = findSocket(sid);
|
|
VKID.remove(s);
|
|
ROLE.remove(s);
|
|
PROTOCOL.remove(s);
|
|
EVENT.remove(s);
|
|
TRACKID.remove(s);
|
|
SOCKETID.remove(s);
|
|
TIME.remove(s);
|
|
PARTYID.remove(s);
|
|
CLIENT.remove(s);
|
|
ONLINE.remove(s);
|
|
httpAuth.remove(s);
|
|
protocolAuth.remove(s);
|
|
}
|
|
|
|
public static Integer getNewID(){
|
|
sid++;
|
|
return sid;
|
|
}
|
|
|
|
public static Integer findSocket(int s){
|
|
int id = -1;
|
|
for (int i = 0; i < SOCKETID.size(); i++) {
|
|
if(SOCKETID.get(i) == s){
|
|
id = i;
|
|
}
|
|
|
|
}
|
|
return id;
|
|
}
|
|
|
|
public static void setHttpAuth(Integer sid, Boolean b){
|
|
int s = findSocket(sid);
|
|
if(s == -1) return;
|
|
httpAuth.set(s, b);
|
|
}
|
|
|
|
public static void setProtocol(Integer sid, Integer vkid, Integer pid, String role){
|
|
int s = findSocket(sid);
|
|
if(s == -1) return;
|
|
protocolAuth.set(s, true);
|
|
VKID.set(s, vkid);
|
|
PARTYID.set(s, pid);
|
|
ROLE.set(s, role);
|
|
}
|
|
|
|
public static Boolean isProtocolAuth(Integer sid){
|
|
int s = findSocket(sid);
|
|
if(s == -1) return Boolean.FALSE;
|
|
return protocolAuth.get(s);
|
|
}
|
|
|
|
public static Boolean isHttpAuth(Integer sid){
|
|
int s = findSocket(sid);
|
|
if(s == -1) return Boolean.FALSE;
|
|
return httpAuth.get(s);
|
|
}
|
|
|
|
public static Boolean isOnline(Integer sid){
|
|
int s = findSocket(sid);
|
|
if(s == -1) return Boolean.FALSE;
|
|
return ONLINE.get(s);
|
|
}
|
|
|
|
public static client getClient(Integer sid){
|
|
int s = findSocket(sid);
|
|
if(s == -1) return null;
|
|
return socketInfo.CLIENT.get(s);
|
|
}
|
|
|
|
|
|
}
|
|
|