Je n'ai pas totalement fini la partie serveur de la lib, mais je peut vous donné un avant gout des fonctions qui seront dispo ainsi qu'un petit example de code. Je voudrais juste avoir votre avis sur mon initiative (faire un lib spéciale birdchat accessible a tous (je sais c'est tordu lol)) et sur le nom des fonctions.
Voilas la liste des fonctions :
Code : Tout sélectionner
; Fonctions "utilisables"
PBNInit()
PBNCreateServer(*ServerCallBack, Port)
PBNRestartServer()
PBNPauseServer(Status.b)
PBNCloseServer()
PBNRegisterIDT(IDT, Priority)
PBNUnregisterIDT(IDT)
PBNSetServerCallBack(*ServerCallBack)
PBNSetTimeOut(TimeOut)
PBNSetMsgDelimiter(chr.s)
PBNSetIDTDelimiter(chr.s)
PBNGetMsgDelimiter()
PBNGetIDTDelimiter()
PBNGetClientIP(ClID)
PBNGetTimeOut()
PBNGetClientConnectionDate(ClID)
PBNGetServerCallback()
PBNGetServerRunningTime()
PBNGetServerStartedDate()
PBNGetServerMaxConnection()
PBNGetServerConnectionNB()
PBNGetServerReceivedBytes()
PBNGetServerSentBytes()
PBNGetServerStatus()
; Fonctions "inutilisables" (je les donnes juste pour "infos")
PBNServerCore(Value)
PBNServerProcessQueue()
PBNServerSendMessage(ClID, IDT, Msg.s)
PBNServerSortMsgQueue(SortType)
PBNCountClientList()
PBNSetClientIP(ClID)
Code : Tout sélectionner
Declare ServerCB(ClID, IDT, Msg.s)
IncludeFile "PBN2.pb"
If PBNInit() = #False
MessageRequester("PBN", "PBNInit() failled!", 0)
End
Else
PBNSetIDTDelimiter(Chr(254))
PBNSetMsgDelimiter(Chr(255))
PBNSetTimeOut(1200)
PBNRegisterIDT(500, 1)
EndIf
OpenWindow(0, 0, 0, 800, 600, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "PBN Server")
CreateGadgetList(WindowID())
EditorGadget(0, 0, 0, 800, 500)
ButtonGadget(1, 5, 505, 50, 20, "Start", #PB_Button_Toggle)
ButtonGadget(2, 60, 505, 50, 20, "Restart")
DisableGadget(2, 1)
ButtonGadget(3, 115, 505, 50, 20, "Pause", #PB_Button_Toggle)
DisableGadget(3, 1)
CreateStatusBar(0, WindowID())
AddStatusBarField(150)
StatusBarText(0, 0, "Server status : Stopped")
AddStatusBarField(100)
StatusBarText(0, 1, "Nb of client : 0")
AddStatusBarField(150)
StatusBarText(0, 2, "RunningTime : 0 s")
AddStatusBarField(150)
StatusBarText(0, 3, "Received bytes : 0")
AddStatusBarField(150)
StatusBarText(0, 3, "Sent bytes : 0")
Timer = GetTickCount_()
Repeat
If GetTickCount_() - Timer >= 1000
Timer = GetTickCount_()
If PBNGetServerStatus() = 0
StatusBarText(0, 0, "Server status : Stopped", #PB_StatusBar_Raised)
ElseIf PBNGetServerStatus() = 1
StatusBarText(0, 0, "Server status : Started", #PB_StatusBar_Raised)
ElseIf PBNGetServerStatus() = 2
StatusBarText(0, 0, "Server status : Paused", #PB_StatusBar_Raised)
EndIf
If PBNGetServerStatus() <> 0
StatusBarText(0, 1, "Nb of client : " + Str(PBNGetServerConnectionNB()))
StatusBarText(0, 2, "RunningTime : " + Str(PBNGetServerRunningTime()) + " s")
StatusBarText(0, 3, "Received bytes : " + Str(PBNGetServerReceivedBytes()))
StatusBarText(0, 4, "Sent bytes : " + Str(PBNGetServerSentBytes()))
EndIf
EndIf
Select WindowEvent()
Case #WM_Close
Quit = #True
Case #PB_Event_Gadget
Select EventGadgetID()
Case 1
If GetGadgetState(1) = 1
SetGadgetText(1, "Stop")
If PBNCreateServer(@ServerCB(), 4003)
DisableGadget(2, 0)
DisableGadget(3, 0)
StatusBarText(0, 0, "Server status : Started", #PB_StatusBar_Raised)
AddGadgetItem(0, -1, "Server started")
AddGadgetItem(0, -1, " Port : 4003")
AddGadgetItem(0, -1, " Starting date : " + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", PBNGetServerStartedDate()))
Else
AddGadgetItem(0, -1, "Unable to create server")
EndIf
Else
DisableGadget(2, 1)
DisableGadget(3, 1)
SetGadgetText(1, "Start")
AddGadgetItem(0, -1, "Server stopped")
PBNCloseServer()
EndIf
Case 2
AddGadgetItem(0, -1, "Restarting server...")
If PBNRestartServer()
AddGadgetItem(0, -1, "Server restarted")
Else
AddGadgetItem(0, -1, "Unable to restart server")
EndIf
Case 3
PBNPauseServer(GetGadgetState(3))
If GetGadgetState(3) = 1
AddGadgetItem(0, -1, "Server paused")
Else
AddGadgetItem(0, -1, "Server running")
EndIf
EndSelect
EndSelect
Delay(1) ; obligatoire
Until Quit = #True
PBNCloseServer()
Procedure ServerCB(ClID, IDT, Msg.s)
Select IDT
Case #PBN_IDT_ClientConnection
AddGadgetItem(0, -1, "Connexion du client : " + Str(ClID))
AddGadgetItem(0, -1, " Client ip : " + PBNGetClientIP(ClID))
AddGadgetItem(0, -1, " Client connection date : " + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", PBNGetClientConnectionDate(ClID)))
AddGadgetItem(0, -1, "")
SendMessage_(GadgetID(0), #EM_SCROLL, #SB_PAGEDOWN, #False)
ProcedureReturn #PBN_DeleteMsg
Case #PBN_IDT_ClientDisconnection
AddGadgetItem(0, -1, "Deconnexion du client : " + Str(ClID))
AddGadgetItem(0, -1, "")
SendMessage_(GadgetID(0), #EM_SCROLL, #SB_PAGEDOWN, #False)
ProcedureReturn #PBN_DeleteMsg
Case 500
AddGadgetItem(0, -1, ">> " + PBNGetClientIP(ClID))
AddGadgetItem(0, -1, Msg)
AddGadgetItem(0, -1, "")
SendMessage_(GadgetID(0), #EM_SCROLL, #SB_PAGEDOWN, #False)
PBNServerSendMessage(-1, 500, ">>Cl" + Str(ClID))
ProcedureReturn #PBN_DeleteMsg
EndSelect
ProcedureReturn #PBN_IgnoreMsg
EndProcedure
Merci
