Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
sbbs
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
Eric
sbbs
Commits
42f86991
Commit
42f86991
authored
13 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
attach user alias and system name to shared-object subscriptions
parent
b25da445
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exec/load/json-client.js
+4
-2
4 additions, 2 deletions
exec/load/json-client.js
exec/load/json-db.js
+22
-12
22 additions, 12 deletions
exec/load/json-db.js
with
26 additions
and
14 deletions
exec/load/json-client.js
+
4
−
2
View file @
42f86991
...
...
@@ -107,14 +107,16 @@ function JSONClient(serverAddr,serverPort) {
this
.
subscribe
=
function
(
scope
,
location
)
{
this
.
send
(
scope
,
"
QUERY
"
,{
oper
:
"
SUBSCRIBE
"
,
location
:
location
,
nick
:
user
?
user
.
alias
:
undefined
,
system
:
system
?
system
.
name
:
undefined
,
location
:
location
});
}
this
.
unsubscribe
=
function
(
scope
,
location
)
{
this
.
send
(
scope
,
"
QUERY
"
,{
oper
:
"
UNSUBSCRIBE
"
,
location
:
location
,
location
:
location
});
}
...
...
This diff is collapsed.
Click to expand it.
exec/load/json-db.js
+
22
−
12
View file @
42f86991
...
...
@@ -73,11 +73,10 @@ function JSONdb (fileName) {
KEEP_READABLE
:
false
,
READ_ONLY
:
false
,
UPDATES
:
false
,
};
/* error constants */
this
.
errors
=
{
/* error constants */
INVALID_REQUEST
:
0
,
OBJECT_NOT_FOUND
:
1
,
NOT_LOCKED
:
2
,
...
...
@@ -87,7 +86,7 @@ function JSONdb (fileName) {
DUPLICATE_SUB
:
6
,
NON_ARRAY
:
7
,
READ_ONLY
:
8
}
}
;
/*************************** database methods ****************************/
/* subscribe a client to an object */
...
...
@@ -350,13 +349,14 @@ function JSONdb (fileName) {
/* return a list of subscriptions and associated IP address for clients */
this
.
who
=
function
(
client
,
record
)
{
var
data
=
[];
for
each
(
var
s
in
record
.
info
.
subscribers
)
{
if
(
!
data
[
s
.
remote_ip_address
])
data
[
s
.
remote_ip_address
]
=
[];
data
[
s
.
remote_ip_address
].
push
(
record
.
location
);
}
for
each
(
var
s
in
record
.
shadow
[
record
.
child_name
].
_subscribers
)
{
data
.
push
({
id
:
s
.
id
,
nick
:
s
.
nick
,
system
:
s
.
system
});
}
log
(
data
.
toSource
());
send_packet
(
client
,
data
,
"
RESPONSE
"
);
return
true
;
}
...
...
@@ -378,6 +378,16 @@ function JSONdb (fileName) {
/* temporary array for queue additions */
var
q
=
[];
/* if there is a username supplied, attach it to the client object */
if
(
query
.
nick
!==
undefined
)
{
client
.
nick
=
query
.
nick
;
}
/* if there is a username supplied, attach it to the client object */
if
(
query
.
system
!==
undefined
)
{
client
.
system
=
query
.
system
;
}
/* if an operation is requested */
if
(
query
.
oper
!==
undefined
)
{
request
=
new
Request
(
client
,
query
.
oper
,
parent_name
,
child_name
,
query
.
data
);
...
...
@@ -396,6 +406,7 @@ function JSONdb (fileName) {
client
,
"
LOCK
"
,
parent_name
,
child_name
,
this
.
settings
.
LOCK_UNLOCK
));
}
/* add the temporary queue to the main queue */
this
.
queue
=
this
.
queue
.
concat
(
q
);
}
...
...
@@ -623,7 +634,7 @@ function JSONdb (fileName) {
this
.
info
=
info
;
}
/* request object generated by
Database.
queue() method
/* request object generated by queue() method
contains the requested object parent, the specific child property requested,
data (in the case of a PUT operation ) */
function
Request
(
client
,
operation
,
parent_name
,
child_name
,
data
)
{
...
...
@@ -811,4 +822,3 @@ function JSONdb (fileName) {
};
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