Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ehasa-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
WIMMA Lab 2019
Overflow
ehasa-frontend
Merge requests
!27
Socket update
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Socket update
socket-update
into
development
Overview
0
Commits
6
Pipelines
0
Changes
2
Merged
L4929
requested to merge
socket-update
into
development
5 years ago
Overview
0
Commits
6
Pipelines
0
Changes
2
Expand
added websocket functionality; back-end sends signals depending on what it receives
adding, editing or deleting drawings prompts updating all drawings
checks for player locations every minute
get drawings and players on socket initialization (getting game ID)
fixed drawing doubles bug
fixed some warnings
0
0
Merge request reports
Viewing commit
c51cfb89
Prev
Next
Show latest version
2 files
+
47
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
c51cfb89
added socket listener
· c51cfb89
Ronnie Friman
authored
5 years ago
src/components/Socket.js
0 → 100644
+
42
−
0
Options
import
React
from
"
react
"
;
import
io
from
"
socket.io-client
"
;
const
socketUrl
=
process
.
env
.
REACT_APP_API_URL
;
export
default
class
ClientSocket
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
// stores the socket object for notifications
sock
:
null
,
// stores updates sent by socket
update
:
null
};
}
// iniate the socket on component mount
componentWillMount
()
{
console
.
log
(
"
iniated socket
"
);
this
.
initSocket
();
}
// disconnect the socket on component dismount
componentWillUnmount
()
{
this
.
state
.
sock
.
disconnect
();
}
initSocket
=
()
=>
{
const
socket
=
io
(
socketUrl
);
// set the socket to listen gameId-thread
socket
.
on
(
this
.
props
.
gameId
,
data
=>
{
// check socket update type
this
.
setState
({
update
:
data
});
console
.
log
(
this
.
state
.
update
);
});
this
.
setState
({
sock
:
socket
});
};
render
()
{
return
null
;
}
}
Loading