mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Protocol 6: node identities, error codes, Synchronous, schema v8, examples
- Protocol 5: a client authenticates as a node (Node), its pushes go to the section's DefaultTopic unless they name one; old Identities refused at start with what to write instead. - Topics listed by name, ids picked and kept by the server; nodes come from client sections, [BakaShrot.Nodes] optional, AcceptNodes = * by default. - Protocol 6: every refusal carries a code, every client failure too (BakaShrot_ErrorCodes.pbi, BakaShrot_GetLastError(), ErrorCode in Python); nothing reconnects by itself, delivery is at least once. - [BakaShrot.Server] Synchronous = FULL (default) or NORMAL, benchmarked. - Schema v8: browse table and browse_messages view for database tools. - Tools renamed BakaShrot<Name>, wait for Enter when started from Explorer. - Examples/SingleServer: a server and a client with scripts (example keys, public on purpose). - Restart-Test.ps1: servers killed mid-traffic and mid-catch-up. - Docs: one server per node rule, DatabaseError() checked per thread, release notes' Compatibility section, Notes "Right now". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVQrLqMQPw9AZnsHqQH
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
; ============================================================================
|
||||
; BakaShrot Tools - Console
|
||||
;
|
||||
; Shared by every tool. Started from Explorer (a double-click, a shortcut),
|
||||
; a console program gets a console of its own that closes as soon as it
|
||||
; ends, before what it printed can be read: ToolConsole_End() waits for
|
||||
; Enter then, and ends at once otherwise.
|
||||
; As https://github.com/aziascreations/PB-Template-Win32-CliApp does it: a
|
||||
; program started from a shell shares the shell's console, one started
|
||||
; directly is alone in its own.
|
||||
; ============================================================================
|
||||
|
||||
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
|
||||
; Not in PureBasic 5.73's API functions, named so it can't clash with a
|
||||
; compiler that has it.
|
||||
Import "kernel32.lib"
|
||||
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
|
||||
ToolConsole_GetConsoleProcessList.l(*ProcessList, ProcessCount.l) As "_GetConsoleProcessList@8"
|
||||
CompilerElse
|
||||
ToolConsole_GetConsoleProcessList.l(*ProcessList, ProcessCount.l) As "GetConsoleProcessList"
|
||||
CompilerEndIf
|
||||
EndImport
|
||||
CompilerEndIf
|
||||
|
||||
|
||||
; #True if the tool was started directly rather than from a shell: it is the
|
||||
; only process on its console. Input or output redirected is #False, someone
|
||||
; else reads it (a test starting it with Start-Process gets a new hidden
|
||||
; console too, alone on it). Always #False outside of Windows.
|
||||
Procedure.i ToolConsole_IsRunDirectly()
|
||||
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
|
||||
Protected Mode.l, ProcessList.q ; ProcessList: room for 2 process ids
|
||||
|
||||
If Not GetConsoleMode_(GetStdHandle_(#STD_INPUT_HANDLE), @Mode)
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
If Not GetConsoleMode_(GetStdHandle_(#STD_OUTPUT_HANDLE), @Mode)
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
ProcedureReturn Bool(ToolConsole_GetConsoleProcessList(@ProcessList, 2) <= 1)
|
||||
CompilerElse
|
||||
ProcedureReturn #False
|
||||
CompilerEndIf
|
||||
EndProcedure
|
||||
|
||||
|
||||
; Ends the tool with ExitCode, after waiting for Enter if it was started
|
||||
; directly (ToolConsole_IsRunDirectly()).
|
||||
Procedure ToolConsole_End(ExitCode.i)
|
||||
If ToolConsole_IsRunDirectly()
|
||||
PrintN("")
|
||||
Print("Press Enter to close...")
|
||||
Input()
|
||||
EndIf
|
||||
End ExitCode
|
||||
EndProcedure
|
||||
Reference in New Issue
Block a user