Some bug fix
This commit is contained in:
+3
-1
@@ -46,7 +46,7 @@
|
|||||||
}</component>
|
}</component>
|
||||||
<component name="RunManager" selected="Attach to Unity Editor.Attach to Unity Editor">
|
<component name="RunManager" selected="Attach to Unity Editor.Attach to Unity Editor">
|
||||||
<configuration name="Standalone Player" type="RunUnityExe" factoryName="Unity Executable">
|
<configuration name="Standalone Player" type="RunUnityExe" factoryName="Unity Executable">
|
||||||
<option name="EXE_PATH" value="$USER_HOME$/OneDrive/Desktop/FlufflPartyBuild/FlufflParty.exe" />
|
<option name="EXE_PATH" value="$USER_HOME$/OneDrive/Desktop/FlufflPartyBuild\FlufflParty.exe" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
<option name="WORKING_DIRECTORY" value="C:\Users\braus\OneDrive\Desktop\FlufflPartyTestBuild" />
|
<option name="WORKING_DIRECTORY" value="C:\Users\braus\OneDrive\Desktop\FlufflPartyTestBuild" />
|
||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
@@ -107,6 +107,8 @@
|
|||||||
<workItem from="1674838735946" duration="520000" />
|
<workItem from="1674838735946" duration="520000" />
|
||||||
<workItem from="1674839572534" duration="23192000" />
|
<workItem from="1674839572534" duration="23192000" />
|
||||||
<workItem from="1674896945068" duration="5207000" />
|
<workItem from="1674896945068" duration="5207000" />
|
||||||
|
<workItem from="1674921006221" duration="833000" />
|
||||||
|
<workItem from="1674945078351" duration="502000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -19,11 +19,9 @@ public class StartHandler : MonoBehaviour
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
client = new TcpClient("185.245.96.48", 8051);
|
|
||||||
|
|
||||||
layout1.SetActive(true);
|
layout1.SetActive(true);
|
||||||
layout2.SetActive(false);
|
layout2.SetActive(false);
|
||||||
|
client = new TcpClient("185.245.96.48", 8051);
|
||||||
buttonJoin.SetActive(false);
|
buttonJoin.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +31,7 @@ public class StartHandler : MonoBehaviour
|
|||||||
byte[] readMessage = new byte[10];
|
byte[] readMessage = new byte[10];
|
||||||
|
|
||||||
//Send message new room
|
//Send message new room
|
||||||
stream.Write(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
stream.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||||
|
|
||||||
layout1.SetActive(false);
|
layout1.SetActive(false);
|
||||||
layout2.SetActive(true);
|
layout2.SetActive(true);
|
||||||
@@ -74,8 +72,7 @@ public class StartHandler : MonoBehaviour
|
|||||||
|
|
||||||
public void ButtonBack()
|
public void ButtonBack()
|
||||||
{
|
{
|
||||||
layout1.SetActive(true);
|
SceneManager.LoadScene(0, LoadSceneMode.Single);
|
||||||
layout2.SetActive(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ButtonCopy()
|
public void ButtonCopy()
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ EditorUserSettings:
|
|||||||
value: 5604555501510a0955590d74437008441216412e7578276829704a6bb0b66c3a
|
value: 5604555501510a0955590d74437008441216412e7578276829704a6bb0b66c3a
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedSceneGuid-1:
|
RecentlyUsedSceneGuid-1:
|
||||||
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
|
value: 0000025f04075d0f0c0a5c7149205a4417154f782e7923357e7a4560e3b4653b
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedSceneGuid-2:
|
RecentlyUsedSceneGuid-2:
|
||||||
value: 0000025f04075d0f0c0a5c7149205a4417154f782e7923357e7a4560e3b4653b
|
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
|
||||||
flags: 0
|
flags: 0
|
||||||
UnityRemoteDevice:
|
UnityRemoteDevice:
|
||||||
value: 225f4d46245b0d4902070862342649191512
|
value: 225f4d46245b0d4902070862342649191512
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ MonoBehaviour:
|
|||||||
width: 1920
|
width: 1920
|
||||||
height: 1117
|
height: 1117
|
||||||
m_ShowMode: 4
|
m_ShowMode: 4
|
||||||
m_Title: Game
|
m_Title: Inspector
|
||||||
m_RootView: {fileID: 6}
|
m_RootView: {fileID: 6}
|
||||||
m_MinSize: {x: 875, y: 300}
|
m_MinSize: {x: 875, y: 300}
|
||||||
m_MaxSize: {x: 10000, y: 10000}
|
m_MaxSize: {x: 10000, y: 10000}
|
||||||
@@ -48,7 +48,7 @@ MonoBehaviour:
|
|||||||
m_MinSize: {x: 300, y: 200}
|
m_MinSize: {x: 300, y: 200}
|
||||||
m_MaxSize: {x: 24288, y: 16192}
|
m_MaxSize: {x: 24288, y: 16192}
|
||||||
vertical: 0
|
vertical: 0
|
||||||
controlID: 78
|
controlID: 71
|
||||||
--- !u!114 &3
|
--- !u!114 &3
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
@@ -94,8 +94,8 @@ MonoBehaviour:
|
|||||||
y: 0
|
y: 0
|
||||||
width: 343
|
width: 343
|
||||||
height: 686
|
height: 686
|
||||||
m_MinSize: {x: 200, y: 200}
|
m_MinSize: {x: 201, y: 221}
|
||||||
m_MaxSize: {x: 4000, y: 4000}
|
m_MaxSize: {x: 4001, y: 4021}
|
||||||
m_ActualView: {fileID: 17}
|
m_ActualView: {fileID: 17}
|
||||||
m_Panes:
|
m_Panes:
|
||||||
- {fileID: 17}
|
- {fileID: 17}
|
||||||
@@ -223,7 +223,7 @@ MonoBehaviour:
|
|||||||
m_MinSize: {x: 200, y: 200}
|
m_MinSize: {x: 200, y: 200}
|
||||||
m_MaxSize: {x: 16192, y: 16192}
|
m_MaxSize: {x: 16192, y: 16192}
|
||||||
vertical: 1
|
vertical: 1
|
||||||
controlID: 557
|
controlID: 103
|
||||||
--- !u!114 &10
|
--- !u!114 &10
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
@@ -248,7 +248,7 @@ MonoBehaviour:
|
|||||||
m_MinSize: {x: 200, y: 100}
|
m_MinSize: {x: 200, y: 100}
|
||||||
m_MaxSize: {x: 16192, y: 8096}
|
m_MaxSize: {x: 16192, y: 8096}
|
||||||
vertical: 0
|
vertical: 0
|
||||||
controlID: 55
|
controlID: 104
|
||||||
--- !u!114 &11
|
--- !u!114 &11
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
@@ -670,14 +670,14 @@ MonoBehaviour:
|
|||||||
m_OverrideSceneCullingMask: 6917529027641081856
|
m_OverrideSceneCullingMask: 6917529027641081856
|
||||||
m_SceneIsLit: 1
|
m_SceneIsLit: 1
|
||||||
m_SceneLighting: 1
|
m_SceneLighting: 1
|
||||||
m_2DMode: 1
|
m_2DMode: 0
|
||||||
m_isRotationLocked: 0
|
m_isRotationLocked: 0
|
||||||
m_PlayAudio: 0
|
m_PlayAudio: 0
|
||||||
m_AudioPlay: 0
|
m_AudioPlay: 0
|
||||||
m_Position:
|
m_Position:
|
||||||
m_Target: {x: 977.5928, y: 457.28116, z: 33874.965}
|
m_Target: {x: 97.37118, y: -10.844384, z: 113.38515}
|
||||||
speed: 2
|
speed: 2
|
||||||
m_Value: {x: 977.5928, y: 457.28116, z: 33874.965}
|
m_Value: {x: 97.37118, y: -10.844384, z: 113.38515}
|
||||||
m_RenderMode: 0
|
m_RenderMode: 0
|
||||||
m_CameraMode:
|
m_CameraMode:
|
||||||
drawMode: 0
|
drawMode: 0
|
||||||
@@ -724,17 +724,17 @@ MonoBehaviour:
|
|||||||
m_GridAxis: 1
|
m_GridAxis: 1
|
||||||
m_gridOpacity: 0.5
|
m_gridOpacity: 0.5
|
||||||
m_Rotation:
|
m_Rotation:
|
||||||
m_Target: {x: 0, y: 0, z: 0, w: 1}
|
m_Target: {x: -0.079544604, y: -0.90466255, z: 0.37537217, w: -0.18539767}
|
||||||
speed: 2
|
speed: 2
|
||||||
m_Value: {x: 0, y: 0, z: 0, w: 1}
|
m_Value: {x: -0.07954388, y: -0.9046543, z: 0.37536877, w: -0.18539599}
|
||||||
m_Size:
|
m_Size:
|
||||||
m_Target: 709.59906
|
m_Target: 18.768896
|
||||||
speed: 2
|
speed: 2
|
||||||
m_Value: 709.59906
|
m_Value: 18.768896
|
||||||
m_Ortho:
|
m_Ortho:
|
||||||
m_Target: 1
|
m_Target: 0
|
||||||
speed: 2
|
speed: 2
|
||||||
m_Value: 1
|
m_Value: 0
|
||||||
m_CameraSettings:
|
m_CameraSettings:
|
||||||
m_Speed: 1.005
|
m_Speed: 1.005
|
||||||
m_SpeedNormalized: 0.5
|
m_SpeedNormalized: 0.5
|
||||||
@@ -748,7 +748,7 @@ MonoBehaviour:
|
|||||||
m_FarClip: 10000
|
m_FarClip: 10000
|
||||||
m_DynamicClip: 1
|
m_DynamicClip: 1
|
||||||
m_OcclusionCulling: 0
|
m_OcclusionCulling: 0
|
||||||
m_LastSceneViewRotation: {x: -0.44589415, y: 0.51905, z: -0.27737507, w: -0.6744397}
|
m_LastSceneViewRotation: {x: -0.08717229, y: 0.89959055, z: -0.21045254, w: -0.3726226}
|
||||||
m_LastSceneViewOrtho: 0
|
m_LastSceneViewOrtho: 0
|
||||||
m_ReplacementShader: {fileID: 0}
|
m_ReplacementShader: {fileID: 0}
|
||||||
m_ReplacementString:
|
m_ReplacementString:
|
||||||
@@ -796,22 +796,22 @@ MonoBehaviour:
|
|||||||
m_SkipHidden: 0
|
m_SkipHidden: 0
|
||||||
m_SearchArea: 1
|
m_SearchArea: 1
|
||||||
m_Folders:
|
m_Folders:
|
||||||
- Assets/Scenes
|
- Assets/Scripts/Start
|
||||||
m_Globs: []
|
m_Globs: []
|
||||||
m_OriginalText:
|
m_OriginalText:
|
||||||
m_ViewMode: 1
|
m_ViewMode: 1
|
||||||
m_StartGridSize: 64
|
m_StartGridSize: 64
|
||||||
m_LastFolders:
|
m_LastFolders:
|
||||||
- Assets/Scenes
|
- Assets/Scripts/Start
|
||||||
m_LastFoldersGridSize: -1
|
m_LastFoldersGridSize: -1
|
||||||
m_LastProjectPath: F:\Projects\Unity\flufflparty\FlufflParty
|
m_LastProjectPath: F:\Projects\Unity\flufflparty\FlufflParty
|
||||||
m_LockTracker:
|
m_LockTracker:
|
||||||
m_IsLocked: 0
|
m_IsLocked: 0
|
||||||
m_FolderTreeState:
|
m_FolderTreeState:
|
||||||
scrollPos: {x: 0, y: 0}
|
scrollPos: {x: 0, y: 0}
|
||||||
m_SelectedIDs: ae5d0000
|
m_SelectedIDs: 985d0000
|
||||||
m_LastClickedID: 23982
|
m_LastClickedID: 23960
|
||||||
m_ExpandedIDs: 00000000285d00002a5d00002c5d00009e5d000000ca9a3b
|
m_ExpandedIDs: 000000003c5d00003e5d0000405d000000ca9a3b
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
@@ -839,7 +839,7 @@ MonoBehaviour:
|
|||||||
scrollPos: {x: 0, y: 0}
|
scrollPos: {x: 0, y: 0}
|
||||||
m_SelectedIDs:
|
m_SelectedIDs:
|
||||||
m_LastClickedID: 0
|
m_LastClickedID: 0
|
||||||
m_ExpandedIDs: 00000000285d00002a5d00002c5d0000
|
m_ExpandedIDs: 000000003c5d00003e5d0000405d0000
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
@@ -915,8 +915,8 @@ MonoBehaviour:
|
|||||||
m_Tooltip:
|
m_Tooltip:
|
||||||
m_Pos:
|
m_Pos:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
x: 1447
|
x: -30553
|
||||||
y: 73
|
y: -31970
|
||||||
width: 472
|
width: 472
|
||||||
height: 1046
|
height: 1046
|
||||||
m_ViewDataDictionary: {fileID: 0}
|
m_ViewDataDictionary: {fileID: 0}
|
||||||
@@ -969,7 +969,7 @@ MonoBehaviour:
|
|||||||
scrollPos: {x: 0, y: 0}
|
scrollPos: {x: 0, y: 0}
|
||||||
m_SelectedIDs:
|
m_SelectedIDs:
|
||||||
m_LastClickedID: 0
|
m_LastClickedID: 0
|
||||||
m_ExpandedIDs: 1831ffff6831ffff4a38ffff5a38ffff843affffd23affffb441ffffc441ffff4850ffff9650ffff7857ffff8857ffffa859fffff859ffffda60ffffea60ffff4e63ffff2868ffff8268ffff4a6fffff666fffff8080ffff2c83ffff8283ffff648affff748affff928cffffe88cffffca93ffffda93ffffe095ffff3696ffff189dffff289dfffff89effff4e9fffff30a6ffff40a6ffffe4d5ffff04fbffff345c0000605c0000965c00009c5c000058a6000036bc000048bc000064bc00007ebc0000aabc0000b4bc0000c4bc0000
|
m_ExpandedIDs: 78ddffffc8ddffffaae4ffffbae4ffff82e6ffffd2e6ffffb4edffffc4edffff9aefffffeaefffffccf6ffffdcf6ffff06fbffff
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
|
|||||||
Generated
+4
-1
@@ -72,7 +72,10 @@
|
|||||||
<updated>1674839030210</updated>
|
<updated>1674839030210</updated>
|
||||||
<workItem from="1674839031467" duration="221000" />
|
<workItem from="1674839031467" duration="221000" />
|
||||||
<workItem from="1674839402490" duration="20380000" />
|
<workItem from="1674839402490" duration="20380000" />
|
||||||
<workItem from="1674897525328" duration="3479000" />
|
<workItem from="1674897525328" duration="3823000" />
|
||||||
|
<workItem from="1674904474316" duration="988000" />
|
||||||
|
<workItem from="1674921351528" duration="2368000" />
|
||||||
|
<workItem from="1674945364389" duration="295000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+53
-12
@@ -4,6 +4,8 @@ import java.io.IOException;
|
|||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class Room
|
public class Room
|
||||||
{
|
{
|
||||||
@@ -18,8 +20,13 @@ public class Room
|
|||||||
|
|
||||||
private int currentPlayer = 0;
|
private int currentPlayer = 0;
|
||||||
|
|
||||||
|
private long timeOut = 0;
|
||||||
|
private Timer t;
|
||||||
|
|
||||||
public Room(String roomCode, Server server)
|
public Room(String roomCode, Server server)
|
||||||
{
|
{
|
||||||
|
timeOut = System.currentTimeMillis();
|
||||||
|
|
||||||
this.roomCode = roomCode;
|
this.roomCode = roomCode;
|
||||||
startPositions = new Vector3[4];
|
startPositions = new Vector3[4];
|
||||||
|
|
||||||
@@ -29,10 +36,31 @@ public class Room
|
|||||||
startPositions[3] = new Vector3(92, 1, 128);
|
startPositions[3] = new Vector3(92, 1, 128);
|
||||||
|
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
t = new Timer();
|
||||||
|
TimerTask tt = new TimerTask()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if(System.currentTimeMillis() - timeOut > 600000)
|
||||||
|
{
|
||||||
|
System.out.println("[" + Server.getDateTime() + "] Room " + roomCode + " closed due to timeout!");
|
||||||
|
server.deleteRoom(roomCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
t.scheduleAtFixedRate(tt, 0, 60000);
|
||||||
|
}catch(Exception e){}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addClient(Client client)
|
public void addClient(Client client)
|
||||||
{
|
{
|
||||||
|
timeOut = System.currentTimeMillis();
|
||||||
|
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
{
|
{
|
||||||
if (players[i] == null)
|
if (players[i] == null)
|
||||||
@@ -40,7 +68,7 @@ public class Room
|
|||||||
players[i] = client;
|
players[i] = client;
|
||||||
playerCount++;
|
playerCount++;
|
||||||
|
|
||||||
System.out.println("Client joined room " + roomCode + " successfully as player " + i);
|
System.out.println("[" + Server.getDateTime() + "] Client joined room " + roomCode + " successfully as player " + i);
|
||||||
|
|
||||||
Thread t = new Thread(new Runnable()
|
Thread t = new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@@ -66,6 +94,8 @@ public class Room
|
|||||||
|
|
||||||
input.read(readData);
|
input.read(readData);
|
||||||
|
|
||||||
|
timeOut = System.currentTimeMillis();
|
||||||
|
|
||||||
switch (readData[0])
|
switch (readData[0])
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -183,39 +213,50 @@ public class Room
|
|||||||
|
|
||||||
public void closeRoom()
|
public void closeRoom()
|
||||||
{
|
{
|
||||||
|
t.cancel();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
players[0].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
if(players[0] != null)
|
||||||
|
{
|
||||||
|
players[0].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
|
}
|
||||||
|
|
||||||
} catch (IOException ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(players[1] != null)
|
||||||
|
{
|
||||||
|
players[1].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
|
}
|
||||||
|
|
||||||
players[1].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
} catch (Exception ex)
|
||||||
|
|
||||||
} catch (IOException ex)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(players[2] != null)
|
||||||
|
{
|
||||||
|
players[2].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
|
}
|
||||||
|
|
||||||
players[2].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
} catch (Exception ex)
|
||||||
|
|
||||||
} catch (IOException ex)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(players[3] != null)
|
||||||
|
{
|
||||||
|
players[3].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
|
}
|
||||||
|
|
||||||
players[3].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
} catch (Exception ex)
|
||||||
|
|
||||||
} catch (IOException ex)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-4
@@ -4,6 +4,8 @@ import java.io.IOException;
|
|||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Server
|
public class Server
|
||||||
@@ -13,26 +15,36 @@ public class Server
|
|||||||
|
|
||||||
private final Server server = this;
|
private final Server server = this;
|
||||||
|
|
||||||
|
private static DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||||
|
|
||||||
|
public static String getDateTime()
|
||||||
|
{
|
||||||
|
return dtf.format(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteRoom(String code)
|
public void deleteRoom(String code)
|
||||||
{
|
{
|
||||||
rooms.get(code).closeRoom();
|
rooms.get(code).closeRoom();
|
||||||
rooms.remove(code);
|
rooms.remove(code);
|
||||||
System.out.println("Room " + code + " successfully deleted");
|
|
||||||
|
|
||||||
|
System.out.println("[" + getDateTime() + "] Room" + code + " successfully deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serverSocket = new ServerSocket(8051);
|
serverSocket = new ServerSocket(8051);
|
||||||
|
|
||||||
System.out.println("Server started! IP 185.245.96.48 PORT 8051");
|
System.out.println("[" + getDateTime() + "] Server started! IP 185.245.96.48 PORT 8051");
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
Socket tempClient = serverSocket.accept();
|
Socket tempClient = serverSocket.accept();
|
||||||
|
|
||||||
System.out.println("Client with IP " + tempClient.getInetAddress().getHostName() + " connected!");
|
System.out.println("[" + getDateTime() + "] Client with IP " + tempClient.getInetAddress().getHostName() + " connected!");
|
||||||
|
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@@ -58,7 +70,7 @@ public class Server
|
|||||||
Room room = new Room(new String(code, StandardCharsets.US_ASCII), server);
|
Room room = new Room(new String(code, StandardCharsets.US_ASCII), server);
|
||||||
rooms.put(new String(code, StandardCharsets.US_ASCII), room);
|
rooms.put(new String(code, StandardCharsets.US_ASCII), room);
|
||||||
|
|
||||||
System.out.println("Room " + new String(code, StandardCharsets.US_ASCII) + " successfully created!");
|
System.out.println("[" + getDateTime() + "] Room " + new String(code, StandardCharsets.US_ASCII) + " successfully created!");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
@@ -106,6 +118,14 @@ public class Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String roomCode = new String(code, StandardCharsets.US_ASCII);
|
||||||
|
|
||||||
|
//avoide double codes (just in case^^)
|
||||||
|
if(rooms.containsKey(roomCode))
|
||||||
|
{
|
||||||
|
code = generateRoomCode();
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user