Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
f4ae402a
Commit
f4ae402a
authored
15 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
Inter-BBS/Inter-node communication client (for use with commservice.js)
parent
3a30afe7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/commclient.js
+78
-0
78 additions, 0 deletions
exec/load/commclient.js
with
78 additions
and
0 deletions
exec/load/commclient.js
0 → 100644
+
78
−
0
View file @
f4ae402a
/*
Inter-BBS/Inter-Node client (for use with commservice.js)
for Synchronet v3.15+
by Matt Johnson - 2009
*/
load
(
"
funclib.js
"
);
load
(
"
sbbsdefs.js
"
);
load
(
"
sockdefs.js
"
);
const
normal_scope
=
"
#
"
;
const
global_scope
=
"
!
"
;
const
priv_scope
=
"
%
"
;
function
GameConnection
(
id
)
{
this
.
session_id
=
(
id
?
id
:
"
default
"
);
//hub should point to the local, internal ip address or domain of the computer running gameservice.js
//port should point to the port the gaming service is set to use in gameservice.js
const
hub
=
"
localhost
"
;
const
port
=
10088
;
const
tries
=
5
;
const
connection_timeout
=
2
;
var
sock
=
new
Socket
();
sock
.
bind
(
0
,
server
.
interface_ip_address
);
this
.
init
=
function
()
{
log
(
"
initializing communication service connection
"
);
for
(
var
t
=
0
;
t
<
tries
;
t
++
)
{
sock
.
connect
(
hub
,
port
,
connection_timeout
);
if
(
sock
.
is_connected
)
{
sock
.
send
(
"
&
"
+
this
.
session_id
+
"
\r\n
"
);
log
(
"
connection to
"
+
hub
+
"
successful
"
);
return
true
;
}
mswait
(
50
);
}
log
(
"
connection to
"
+
hub
+
"
failed with error
"
+
sock
.
last_error
);
return
false
;
}
this
.
receive
=
function
()
{
var
data
=
0
;
if
(
!
sock
.
is_connected
)
{
log
(
"
connecting to hub
"
);
if
(
!
this
.
init
())
return
-
1
;
}
if
(
sock
.
data_waiting
)
{
var
raw_data
=
sock
.
recvline
(
4092
,
connection_timeout
);
data
=
js
.
eval
(
raw_data
);
}
return
data
;
}
this
.
send
=
function
(
data
)
{
if
(
!
sock
.
is_connected
)
{
log
(
"
connecting to hub
"
);
if
(
!
this
.
init
())
return
-
1
;
}
if
(
!
data
.
scope
)
{
log
(
"
scope undefined
"
);
return
-
1
;
}
var
packet
=
data
.
scope
+
this
.
session_id
+
"
:
"
+
data
.
toSource
()
+
"
\r\n
"
;
sock
.
send
(
packet
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment