请问哪位高手有研究过多人聊天的代码,我有些很不懂,下面这些代码从网上找来看看的
Private client As TcpClient
Private readBuffer(READ_BUFFER_SIZE) As Byte
Private strName As String ' 类对象属性Name
Public Property Name() As String
Get
Return strName
End Get
Set(ByVal Value As String)
strName = Value
End Set
End Property
Public Event LineReceived(ByVal sender As UserConnection, ByVal Data As String) '发送信息
Public Sub SendData(ByVal Data As String)
' 锁定当前时间没有其它的在读取信息流
SyncLock client.GetStream
Dim writer As New IO.StreamWriter(client.GetStream)
writer.Write(Data & Chr(13) & Chr(10)) ' Flush信息.
writer.Flush()
End SyncLock
End Sub
虽然有些解析,但不能完全读弄意思。望解答啊,比如这里定义了 Public Event LineReceived后还定义Public Sub SendData,这样又不会出错,怎么回事?
Private client As TcpClient
Private readBuffer(READ_BUFFER_SIZE) As Byte
Private strName As String ' 类对象属性Name
Public Property Name() As String
Get
Return strName
End Get
Set(ByVal Value As String)
strName = Value
End Set
End Property
Public Event LineReceived(ByVal sender As UserConnection, ByVal Data As String) '发送信息
Public Sub SendData(ByVal Data As String)
' 锁定当前时间没有其它的在读取信息流
SyncLock client.GetStream
Dim writer As New IO.StreamWriter(client.GetStream)
writer.Write(Data & Chr(13) & Chr(10)) ' Flush信息.
writer.Flush()
End SyncLock
End Sub
虽然有些解析,但不能完全读弄意思。望解答啊,比如这里定义了 Public Event LineReceived后还定义Public Sub SendData,这样又不会出错,怎么回事?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货