Why the hell wont this compile?
MainApp.bmx
Framework BRL.StandardIO
Import "ConnectionMonitor.bmx"
Import "ActiveClient.bmx"
SuperStrict
'Global DEBUG_APP:Int = 0
Global EXIT_APP:Int = 0
ConnectionMonitor.CreateTcp( 9050 )
While Not EXIT_APP
'If KeyDown(KEY_ESCAPE) Then EXIT_APP = 1
ConnectionMonitor.Update()
ActiveClient.Update()
Wend
ConnectionMonitor.DestroyAll()
End
ConnectionMonitor.bmx
Import BRL.LinkedList
Import BRL.Socket
Import "Client.bmx"
Strict
Type ConnectionMonitor
Global ConnectionMonitors:TList = CreateList()
Field port:Int, socketType:Int
Field socket:TSocket
Field monitorLink:TLink
Function CreateTcp( port:Int )
Local monitor:ConnectionMonitor = New ConnectionMonitor
monitor.port = port
monitor.socket = CreateTCPSocket()
If Not BindSocket( monitor.socket, monitor.port) Or Not SocketListen( monitor.socket ) Then
Print "Unable to bind TCPSocket to:" + port
CloseSocket( monitor.socket )
Return
EndIf
monitorLink = ConnectionMonitors.AddLast( client )
End Function
Function CreateUdp( port:Int )
End Function
Function Update()
Local monitor:ConnectionMonitor
For monitor = EachIn ConnectionMonitors
monitor._Update()
Next
End Function
Function DestroyAll()
Local monitor:ConnectionMonitor
For monitor = EachIn ConnectionMonitors
monitor.Destroy()
Next
End Function
Method Destroy()
monitorLink.Remove()
CloseSocket( socket )
End Method
Method _Update()
Select socketType
Case 0
Local newSocket:TSocket = SocketAccept( socket )
If newSocket Then CClient.Create( newSocket )
Case 1
End Select
End Method
End Type
NetworkId.bmx
Import "Client.bmx"
Strict
Type NetworkID
Global NetworkIDArray:CClient[] = New CClient[50]
Function AquireId:Int( client:CClient )
For idIndex:Int = 1 To ( NetworkIDArray.length - 1 )
If NetworkIDArray[ idIndex ] = Null Then
NetworkIDArray[ idIndex ] = client
Return idIndex
EndIf
Next
Return 0
End Function
Function ReleaseId( currentID:Int )
NetworkIDArray[ currentID ] = Null
End Function
Function GetClient:CClient( atId:Int )
Return NetworkIDArray[ atId ]
End Function
End Type
ActiveClient.bmx
Import BRL.LinkedList
Import "Client.bmx"
Strict
Type ActiveClient
Global ActiveClientList:TList = CreateList()
Function Add:TLink( client:CClient )
If client = Null Then Return Null
Return ActiveClientList.AddLast( client )
End Function
Function Remove( clientLink:TLink )
If clientLink = Null Then Return
clientLink.Remove()
End Function
Function Update()
Local client:CClient
For client = EachIn ActiveClientList
client.Update()
Next
End Function
End Type
Client.bmx
Import BRL.LinkedList
Import BRL.Socket
Import "NetworkId.bmx"
Import "ActiveClient.bmx"
Strict
Type CClient
Field activeClientLink:TLink
Field networkID:Int, ip:Int, port:Int, lastActivityMs:Int
Field tcpSocket:TSocket, udpSocket:TSocket
Field ipString:String
Method Update()
If Not Connected() Then Return
End Method
Method Connected:Int()
If MilliSecs() - lastActivityMs > 5000 Then
Destroy()
Return False
EndIf
Return True
End Method
Function Create( socket:TSocket )
Local client:CClient= New CClient
client.networkID = NetworkID.AquireId( client )
client.activeClientLink = ActiveClient.Add( client )
client.tcpSocket = socket
EndFunction
Method Destroy()
activeClientLink.Remove()
activeClientLink = Null
NetworkID.ReleaseId( networkID )
networkID = 0
End Method
End Type
It keeps erring: "Unable to open file '.bmx/Client.bmx.debug.win32.x86.i'
|