Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
skylivex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
astronomy
skylivex
Commits
8be07439
Commit
8be07439
authored
Feb 19, 2013
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial stesure of the protocol parser
parent
0cb02de2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
9 deletions
+64
-9
SkyliveX.js
gui/SkyliveX.js
+10
-1
splash.html
gui/splash.html
+6
-0
skproto.cpp
plugins/skproto.cpp
+8
-4
skproto.h
plugins/skproto.h
+37
-3
mainwin.cpp
src/mainwin.cpp
+2
-1
mainwin.h
src/mainwin.h
+1
-0
No files found.
gui/SkyliveX.js
View file @
8be07439
function
changeContent
(
id
,
content
)
function
changeContent
(
id
,
content
)
{
{
document
.
getElementById
(
id
).
innerHTML
=
content
;
var
n
=
document
.
getElementById
(
id
);
if
(
typeof
(
n
)
!=
"undefined"
)
n
.
innerHTML
=
content
;
}
function
notify
(
content
)
{
if
(
typeof
(
notifycb
)
==
"function"
)
notifycb
(
content
);
}
}
SkyliveX
.
changeContent
.
connect
(
changeContent
);
SkyliveX
.
changeContent
.
connect
(
changeContent
);
SkyliveX
.
notify
.
connect
(
notify
);
gui/splash.html
View file @
8be07439
<html>
<html>
<head>
<head>
<title>
SkyliveX
</title>
<title>
SkyliveX
</title>
<script
type=
"text/javascript"
>
function
notifycb
(
content
)
{
document
.
getElementById
(
"loadstring"
).
innerHTML
=
content
;
}
</script>
<script
type=
"text/javascript"
src=
"SkyliveX.js"
></script>
<script
type=
"text/javascript"
src=
"SkyliveX.js"
></script>
<style>
<style>
#loading
{
#loading
{
...
...
plugins/skproto.cpp
View file @
8be07439
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
void
SkyliveProtocol
::
startPlugin
()
void
SkyliveProtocol
::
startPlugin
()
{
{
SM_TCPCLIENT
=
HOME
;
std
::
cout
<<
"SkyliveProtocol initialized in thread "
<<
thread
()
<<
std
::
endl
;
std
::
cout
<<
"SkyliveProtocol initialized in thread "
<<
thread
()
<<
std
::
endl
;
registerHandler
((
QString
)
"connectTelescopes"
,
&
SkyliveProtocol
::
handle_connect
);
registerHandler
((
QString
)
"connectTelescopes"
,
&
SkyliveProtocol
::
handle_connect
);
}
}
...
@@ -49,22 +50,25 @@ void SkyliveProtocol::startPlugin()
...
@@ -49,22 +50,25 @@ void SkyliveProtocol::startPlugin()
void
SkyliveProtocol
::
readFromNetwork
()
void
SkyliveProtocol
::
readFromNetwork
()
{
{
char
buffer
[
50
];
char
buffer
[
1024
];
int
ba
=
tcpSocket
->
bytesAvailable
();
std
::
cout
<<
"Bytes: "
<<
ba
<<
std
::
endl
;
while
(
tcpSocket
->
bytesAvailable
())
while
(
tcpSocket
->
bytesAvailable
())
{
{
tcpSocket
->
read
(
buffer
,
50
);
tcpSocket
->
read
(
buffer
,
1024
);
std
::
cout
<<
"Received From Skylive Server: "
<<
buffer
<<
std
::
endl
;
std
::
cout
<<
"Received From Skylive Server: "
<<
buffer
<<
std
::
endl
;
}
}
}
}
void
SkyliveProtocol
::
handle_connect
(
SKMessage
::
SKMessage
msg
)
void
SkyliveProtocol
::
handle_connect
(
SKMessage
::
SKMessage
msg
)
{
{
std
::
cout
<<
"SkyliveProtocol connect : "
<<
msg
.
handle
.
toStdString
()
<<
std
::
endl
;
authenticated
=
false
;
std
::
cout
<<
"SkyliveProtocol connect: "
<<
msg
.
handle
.
toStdString
()
<<
std
::
endl
;
tcpSocket
=
new
QTcpSocket
(
this
);
tcpSocket
=
new
QTcpSocket
(
this
);
connect
(
tcpSocket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readFromNetwork
()));
connect
(
tcpSocket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readFromNetwork
()));
connect
(
tcpSocket
,
SIGNAL
(
error
(
QAbstractSocket
::
SocketError
)),
this
,
SLOT
(
displayError
(
QAbstractSocket
::
SocketError
)));
connect
(
tcpSocket
,
SIGNAL
(
error
(
QAbstractSocket
::
SocketError
)),
this
,
SLOT
(
displayError
(
QAbstractSocket
::
SocketError
)));
tcpSocket
->
abort
();
tcpSocket
->
abort
();
tcpSocket
->
connectToHost
(
"www.skylive.name"
,
8080
);
tcpSocket
->
connectToHost
(
SERVERHOST
,
SERVERPORT
);
}
}
void
SkyliveProtocol
::
receiveMessage
(
SKMessage
::
SKMessage
msg
)
void
SkyliveProtocol
::
receiveMessage
(
SKMessage
::
SKMessage
msg
)
...
...
plugins/skproto.h
View file @
8be07439
...
@@ -32,14 +32,46 @@
...
@@ -32,14 +32,46 @@
* Purpose:
* Purpose:
*
*
*/
*/
#ifndef SKPROTO_H
#define SKPROTO_H
#include <QObject>
#include <QObject>
#include <QtPlugin>
#include <QtPlugin>
#include <QHash>
#include <QHash>
#include <QTcpSocket>
#include <QTcpSocket>
#include <QNetworkSession>
//#include <QNetworkSession>
#include <QByteArray>
#include "pluginsinterfaces.h"
#include "pluginsinterfaces.h"
#include "ipcmsg.h"
#include "ipcmsg.h"
#define SERVERHOST "www.skylive.name"
#define SERVERPORT 8080
struct
SKProtoMsg
{
QByteArray
cmd
;
QByteArray
params
;
QByteArray
crc
;
};
enum
_SM_TCPCLIENT
{
HOME
=
0
,
CONNECTED
,
COMMAND
,
PARAMS
,
CRC
};
//SM_TCPCLIENT = HOME;
#define PROTO_START "["
#define PROTO_END "]"
#define CMD_END ">"
#define PARAM_SEPARATOR "|"
#define PARAM_END ":"
class
SkyliveProtocol
;
class
SkyliveProtocol
;
typedef
void
(
SkyliveProtocol
::*
SKHandlerFunction
)(
SKMessage
::
SKMessage
);
typedef
void
(
SkyliveProtocol
::*
SKHandlerFunction
)(
SKMessage
::
SKMessage
);
...
@@ -53,7 +85,9 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
...
@@ -53,7 +85,9 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
private
:
private
:
QHash
<
QString
,
SKHandlerFunction
>
_handlers
;
QHash
<
QString
,
SKHandlerFunction
>
_handlers
;
QTcpSocket
*
tcpSocket
;
QTcpSocket
*
tcpSocket
;
QNetworkSession
*
networkSession
;
//QNetworkSession *networkSession;
bool
authenticated
;
_SM_TCPCLIENT
SM_TCPCLIENT
;
public
:
public
:
...
@@ -72,4 +106,4 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
...
@@ -72,4 +106,4 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
signals
:
signals
:
void
putMessage
(
SKMessage
::
SKMessage
msg
);
void
putMessage
(
SKMessage
::
SKMessage
msg
);
};
};
#endif
src/mainwin.cpp
View file @
8be07439
...
@@ -98,7 +98,7 @@ void MainWin::handle_corestarted(SKMessage::SKMessage &msg)
...
@@ -98,7 +98,7 @@ void MainWin::handle_corestarted(SKMessage::SKMessage &msg)
{
{
msg
.
handle
=
"connectTelescopes"
;
msg
.
handle
=
"connectTelescopes"
;
sendMessage
(
msg
);
sendMessage
(
msg
);
jsbridge
.
changePageContent
(
"loadstring"
,
"Connecting..."
);
jsbridge
.
notify
(
"Connecting..."
);
}
}
...
@@ -106,3 +106,4 @@ void JSBridge::changePageContent(QString elementid, QString content)
...
@@ -106,3 +106,4 @@ void JSBridge::changePageContent(QString elementid, QString content)
{
{
emit
changeContent
(
elementid
,
content
);
emit
changeContent
(
elementid
,
content
);
}
}
src/mainwin.h
View file @
8be07439
...
@@ -63,6 +63,7 @@ class JSBridge : public QObject
...
@@ -63,6 +63,7 @@ class JSBridge : public QObject
signals
:
signals
:
void
changeContent
(
QString
elementid
,
QString
content
);
void
changeContent
(
QString
elementid
,
QString
content
);
void
notify
(
QString
content
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment