Files
BlitzSteam/Resources/Examples/SteamMatchmakingServers_Example.bb
T

90 lines
3.3 KiB
BlitzBasic
Raw Normal View History

2016-05-08 22:46:41 +02:00
; BlitzSteam - Steam wrapper for Blitz
; Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation, either version 3 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
Include "../BlitzSteam.bb"
;----------------------------------------------------------------
;! Configuration
;----------------------------------------------------------------
Const APPID = 480 ; Test App / SpaceWar
Const FRAMERATE = 60
Const RESOLUTION_X = 1024
Const RESOLUTION_Y = 768
Const RESOLUTION_Z = 32
Const RESOLUTION_MODE = 2
;----------------------------------------------------------------
;! Init Code
;----------------------------------------------------------------
Global Timer = CreateTimer(FRAMERATE)
2016-07-29 22:20:13 +02:00
Global ServerListResponse_ServerResponded_p%:ServerListResponse_ServerResponded(0, 0, 0)
Global ServerListResponse_RefreshComplete_p%:ServerListResponse_RefreshComplete(0, 0, 0)
2016-05-08 22:46:41 +02:00
Graphics3D RESOLUTION_X, RESOLUTION_Y, RESOLUTION_Z, RESOLUTION_MODE
2016-05-08 22:46:41 +02:00
SetBuffer BackBuffer()
If Not BS_SteamAPI_Init() Then RuntimeError "Failed to initialize Steam!"
;----------------------------------------------------------------
;! Main Code
;----------------------------------------------------------------
Local Bank =CreateBank(1)
2016-07-29 22:20:13 +02:00
Local pRequestServersResponse = BS_ISteamMatchmakingServerListResponse_New(0, ServerListResponse_ServerResponded_p, 0, ServerListResponse_RefreshComplete_p)
2016-05-08 22:46:41 +02:00
Local hRequest = BS_ISteamMatchmakingServers_RequestInternetServerList(BS_SteamMatchmakingServers(), 480, Bank, 0, pRequestServersResponse)
While Not KeyHit(1)
WaitTimer Timer
BS_SteamAPI_RunCallbacks()
Wend
BS_ISteamMatchmakingServers_ReleaseRequest(BS_SteamMatchmakingServers(), hRequest)
BS_SteamAPI_Shutdown()
;----------------------------------------------------------------
;! Functions
;----------------------------------------------------------------
2016-07-29 22:20:13 +02:00
Function ServerListResponse_ServerResponded(pData%, hRequest%, iServer%)
2016-05-08 22:46:41 +02:00
If (Not ServerListResponse_ServerResponded_p)
ServerListResponse_ServerResponded_p = BP_GetFunctionPointer()
Return
EndIf
Print iServer
2016-07-29 22:20:13 +02:00
Return
2016-05-08 22:46:41 +02:00
End Function
2016-07-29 22:20:13 +02:00
Function ServerListResponse_RefreshComplete(pData%, hRequest%, eMatchMakingServerResponse%)
2016-05-08 22:46:41 +02:00
If (Not ServerListResponse_RefreshComplete_p)
ServerListResponse_RefreshComplete_p = BP_GetFunctionPointer()
Return
EndIf
Select eMatchMakingServerResponse
Case BS_EMatchMakingServerResponse_ServerResponded
Print "Got Servers"
Case BS_EMatchMakingServerResponse_ServerFailedToRespond
Print "Server did not respond"
Case BS_EMatchMakingServerResponse_NoServersListedOnMasterServer
Print "No Servers listed for this game."
Default
Print "Unknown"
End Select
2016-07-29 22:20:13 +02:00
Return
2016-05-08 22:46:41 +02:00
End Function
;~IDEal Editor Parameters:
;~C#Blitz3D