Skip to content

Commit

Permalink
feat: Rename socket classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Feb 18, 2025
1 parent 70d35ee commit a64ac3c
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Assets/JCSUnity/Scripts/Managers/JCS_NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void Test()
bytesSend[2] = (byte)'l';
bytesSend[3] = (byte)'L';
bytesSend[4] = (byte)'o';
JCS_NetworkSettings.GetGameSocket().SendPacket(bytesSend);
JCS_NetworkSettings.GetSocket().SendPacket(bytesSend);
}

if (JCS_Input.GetKeyDown(KeyCode.O))
Expand All @@ -79,7 +79,7 @@ private void Test()
bytesSend[7] = (byte)',';
bytesSend[8] = (byte)'.';
bytesSend[9] = (byte)'/';
JCS_NetworkSettings.GetGameSocket().SendPacket(bytesSend);
JCS_NetworkSettings.GetSocket().SendPacket(bytesSend);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* $File: JCS_GameSocket.cs $
* $File: JCS_Socket.cs $
* $Date: 2017-08-31 16:01:58 $
* $Revision: $
* $Creator: Jen-Chieh Shen $
Expand All @@ -12,7 +12,7 @@ namespace JCSUnity
/// <summary>
/// Socket Interface.
/// </summary>
public interface JCS_GameSocket
public interface JCS_Socket
{
/// <summary>
/// Connect to the server.
Expand Down
6 changes: 3 additions & 3 deletions Assets/JCSUnity/Scripts/Network/JCS_PacketLostPreventer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ protected override void TransferData(JCS_PacketLostPreventer _old, JCS_PacketLos
/// </summary>
private void TrackPacket()
{
if (JCS_NetworkSettings.GetGameSocket() != null &&
!JCS_NetworkSettings.GetGameSocket().IsConnected())
if (JCS_NetworkSettings.GetSocket() != null &&
!JCS_NetworkSettings.GetSocket().IsConnected())
return;

mResendTimer += Time.unscaledDeltaTime;
Expand Down Expand Up @@ -200,7 +200,7 @@ already responded. */
JCS_Packet packet = mWaitingPackets[index];

// re-send the packet
JCS_NetworkSettings.GetGameSocket().SendPacket(packet.GetBytes());
JCS_NetworkSettings.GetSocket().SendPacket(packet.GetBytes());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* $File: JCS_TCPGameSocket.cs $
* $File: JCS_TCPSocket.cs $
* $Date: 2017-08-21 16:38:46 $
* $Revision: $
* $Creator: Jen-Chieh Shen $
Expand All @@ -16,7 +16,7 @@ namespace JCSUnity
/// <summary>
/// Socket Descriptor holder.
/// </summary>
public class JCS_TCPGameSocket : JCS_GameSocket
public class JCS_TCPSocket : JCS_Socket
{
/* Variables */

Expand All @@ -43,7 +43,7 @@ public void SetHandler(JCS_ClientHandler handler)

/* Functions */

public JCS_TCPGameSocket(JCS_ClientHandler handler = null)
public JCS_TCPSocket(JCS_ClientHandler handler = null)
{
if (handler != null)
SetHandler(handler);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* $File: JCS_UDPGameSocket.cs $
* $File: JCS_UDPSocket.cs $
* $Date: 2017-08-30 18:20:10 $
* $Revision: $
* $Creator: Jen-Chieh Shen $
Expand All @@ -16,7 +16,7 @@ namespace JCSUnity
/// <summary>
/// UDP Socket.
/// </summary>
public class JCS_UDPGameSocket : JCS_GameSocket
public class JCS_UDPSocket : JCS_Socket
{
/* Variables */

Expand All @@ -43,7 +43,7 @@ public void SetHandler(JCS_ClientHandler handler)

/* Functions */

public JCS_UDPGameSocket(JCS_ClientHandler handler = null)
public JCS_UDPSocket(JCS_ClientHandler handler = null)
{
if (handler != null)
SetHandler(handler);
Expand Down
27 changes: 13 additions & 14 deletions Assets/JCSUnity/Scripts/Settings/JCS_NetworkSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class JCS_NetworkSettings : JCS_Settings<JCS_NetworkSettings>
[Tooltip("Channel count in this game.")]
public int CHANNEL_COUNT = 1;

private static JCS_GameSocket GAME_SOCKET = null;
private static JCS_Socket SOCKET = null;
private static JCS_ClientHandler PRESET_CLIENT_HANDLER = null;

private JCS_ServerRequestProcessor mServerRequestProcessor = null;
Expand Down Expand Up @@ -97,8 +97,7 @@ public static bool CreateNetwork(string hostname, int port)
return CreateNetwork(hostname, port, GetPresetClientHandler());
}

/// <returns></returns>
/// /// <summary>
/// <summary>
/// Create the socket and connect to the host and
/// port provided.
/// </summary>
Expand All @@ -108,18 +107,18 @@ public static bool CreateNetwork(string hostname, int port)
/// <returns> Sucess or vice versa. </returns>
public static bool CreateNetwork(string hostname, int port, JCS_ClientHandler handler)
{
if (GAME_SOCKET != null)
if (SOCKET != null)
return false;

if (instance.PROTOCAL_TYPE == JCS_ProtocalType.TCP)
{
GAME_SOCKET = new JCS_TCPGameSocket(handler);
GAME_SOCKET.Connect(hostname, port);
SOCKET = new JCS_TCPSocket(handler);
SOCKET.Connect(hostname, port);
}
else if (instance.PROTOCAL_TYPE == JCS_ProtocalType.UDP)
{
GAME_SOCKET = new JCS_UDPGameSocket(handler);
GAME_SOCKET.Connect(hostname, port);
SOCKET = new JCS_UDPSocket(handler);
SOCKET.Connect(hostname, port);
}

return true;
Expand All @@ -130,20 +129,20 @@ public static bool CreateNetwork(string hostname, int port, JCS_ClientHandler ha
/// </summary>
public static void CloseSocket()
{
if (GAME_SOCKET == null)
if (SOCKET == null)
return;

GAME_SOCKET.Close();
GAME_SOCKET = null;
SOCKET.Close();
SOCKET = null;
}

/// <summary>
/// Return the Game socket we are using.
/// Return the socket we are using.
/// </summary>
/// <returns> socket. </returns>
public static JCS_GameSocket GetGameSocket()
public static JCS_Socket GetSocket()
{
return GAME_SOCKET;
return SOCKET;
}

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions docs/ScriptReference/Network/Interface/JCS_GameSocket.md

This file was deleted.

3 changes: 3 additions & 0 deletions docs/ScriptReference/Network/Interface/JCS_Socket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# JCS_Socket

Socket interface.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JCS_TCPGameSocket
# JCS_TCPSocket

TCP socket class.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# JCS_UDPGameSocket
# JCS_UDPSocket

UDP socket class.

Functions
## Functions

| Name | Description |
|:-------------------------|:------------------------------------------------------------|
Expand Down

0 comments on commit a64ac3c

Please sign in to comment.