File tree 2 files changed +8
-4
lines changed
Demo/API_V2/Assets/API/Network
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 6
6
public class TCPSocket : Details
7
7
{
8
8
private WXTCPSocket _tcpSocket ;
9
+
9
10
private bool _connected = false ;
10
11
11
12
// 数据
@@ -29,6 +30,7 @@ protected override void TestAPI(string[] args)
29
30
if ( _tcpSocket == null )
30
31
{
31
32
_tcpSocket = WX . CreateTCPSocket ( ) ;
33
+
32
34
Debug . Log ( "tcpSocket: " + JsonUtility . ToJson ( _tcpSocket ) ) ;
33
35
34
36
_tcpSocket . OnMessage ( ( res ) => {
@@ -48,7 +50,7 @@ protected override void TestAPI(string[] args)
48
50
} ) ;
49
51
} else
50
52
{
51
- Debug . Log ( "tcp实例已初始化" ) ;
53
+ Debug . LogError ( "tcp实例已初始化" ) ;
52
54
}
53
55
54
56
}
@@ -59,9 +61,10 @@ private void close()
59
61
{
60
62
_tcpSocket . Close ( ) ;
61
63
_connected = false ;
64
+ _tcpSocket = null ;
62
65
} else
63
66
{
64
- Debug . Log ( "关闭失败:tcp实例未初始化或未连接" ) ;
67
+ Debug . LogError ( "关闭失败:tcp实例未初始化或未连接" ) ;
65
68
}
66
69
67
70
}
@@ -77,7 +80,7 @@ private void connect() {
77
80
_connected = true ;
78
81
} else
79
82
{
80
- Debug . Log ( "连接失败:tcp实例未初始化或已连接" ) ;
83
+ Debug . LogError ( "连接失败:tcp实例未初始化或已连接" ) ;
81
84
}
82
85
}
83
86
@@ -102,7 +105,7 @@ private void write() {
102
105
}
103
106
} else
104
107
{
105
- Debug . Log ( "发送失败:tcp实例未初始化或未连接" ) ;
108
+ Debug . LogError ( "发送失败:tcp实例未初始化或未连接" ) ;
106
109
}
107
110
}
108
111
}
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ private void close() {
125
125
{
126
126
_udpSocket . Close ( ) ;
127
127
_connected = false ;
128
+ _udpSocket = null ;
128
129
} else
129
130
{
130
131
Debug . LogError ( "关闭失败:udp实例未初始化或未连接" ) ;
You can’t perform that action at this time.
0 commit comments