mirror of
https://github.com/TheGreyDiamond/Enlight.git
synced 2026-03-31 14:50:24 +02:00
session test
This commit is contained in:
21
index.js
21
index.js
@@ -11,6 +11,7 @@ const { win32 } = require("path");
|
|||||||
const sysInf = require("systeminformation");
|
const sysInf = require("systeminformation");
|
||||||
const dgram = require("dgram");
|
const dgram = require("dgram");
|
||||||
var server = dgram.createSocket("udp4");
|
var server = dgram.createSocket("udp4");
|
||||||
|
var client = dgram.createSocket("udp4");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const { time } = require("console");
|
const { time } = require("console");
|
||||||
const { nanoid } = require("nanoid");
|
const { nanoid } = require("nanoid");
|
||||||
@@ -43,6 +44,7 @@ pageLookup["header"] = "header.html";
|
|||||||
// 2 Connected as host
|
// 2 Connected as host
|
||||||
// 3 Connected as Client
|
// 3 Connected as Client
|
||||||
// 4 Connection failed
|
// 4 Connection failed
|
||||||
|
// 5 Searching
|
||||||
|
|
||||||
var sessionState = -1;
|
var sessionState = -1;
|
||||||
var sessionStateGoal = -1;
|
var sessionStateGoal = -1;
|
||||||
@@ -348,6 +350,25 @@ function init() {
|
|||||||
sessionState = 1;
|
sessionState = 1;
|
||||||
sessionStateGoal = 2;
|
sessionStateGoal = 2;
|
||||||
event.returnValue = "";
|
event.returnValue = "";
|
||||||
|
} else if(String(arg).includes("SESSION:startSearch")){
|
||||||
|
console.log("starting search")
|
||||||
|
client.bind(PORT);
|
||||||
|
|
||||||
|
client.on('listening', function () {
|
||||||
|
console.log("look")
|
||||||
|
// Get and print udp server listening ip address and port number in log console.
|
||||||
|
var address = client.address();
|
||||||
|
console.log('UDP client started and listening on ' + address.address + ":" + address.port);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on("message", function (message) {
|
||||||
|
// Create output message.
|
||||||
|
var output = "Udp server receive message : " + message + "\n";
|
||||||
|
// Print received message in stdout, here is log console.
|
||||||
|
console.log(output)
|
||||||
|
});
|
||||||
|
sessionState = 5;
|
||||||
|
event.returnValue = "";
|
||||||
} else {
|
} else {
|
||||||
event.returnValue = "ERR:UNKNOW_CMD";
|
event.returnValue = "ERR:UNKNOW_CMD";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Go back</button>
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Go back</button>
|
||||||
<state>Sessionstate: <state id = "sessionStateText">unknown</state></state>
|
<state>Sessionstate: <state id = "sessionStateText">unknown</state></state>
|
||||||
<script>
|
<script>
|
||||||
connectionStatesAsText = {"-1": "Unknown", "0": "Not connected to a session", "1": "Connecting...", "2": "Hosting", "3": "Connected", "4": "Connection failed"};
|
connectionStatesAsText = {"-1": "Unknown", "0": "Not connected to a session", "1": "Connecting...", "2": "Hosting", "3": "Connected", "4": "Connection failed", "5": "Seraching"};
|
||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
connectionState = ipcRenderer.sendSync("synchronous-message", "SESSION:get.state");
|
connectionState = ipcRenderer.sendSync("synchronous-message", "SESSION:get.state");
|
||||||
document.getElementById("sessionStateText").innerHTML = connectionStatesAsText[String(connectionState)];
|
document.getElementById("sessionStateText").innerHTML = connectionStatesAsText[String(connectionState)];
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
<button onclick='createNewSession()'>
|
<button onclick='createNewSession()'>
|
||||||
Create new session
|
Create new session
|
||||||
</button>
|
</button>
|
||||||
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "SESSION:startSearch");'>
|
||||||
|
Start session search
|
||||||
|
</button>
|
||||||
<script>
|
<script>
|
||||||
function createNewSession() {
|
function createNewSession() {
|
||||||
val = document.getElementById("sessionName").value
|
val = document.getElementById("sessionName").value
|
||||||
|
|||||||
@@ -207,7 +207,7 @@
|
|||||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Go back</button>
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Go back</button>
|
||||||
<state>Sessionstate: <state id = "sessionStateText">unknown</state></state>
|
<state>Sessionstate: <state id = "sessionStateText">unknown</state></state>
|
||||||
<script>
|
<script>
|
||||||
connectionStatesAsText = {"-1": "Unknown", "0": "Not connected to a session", "1": "Connecting...", "2": "Hosting", "3": "Connected", "4": "Connection failed"};
|
connectionStatesAsText = {"-1": "Unknown", "0": "Not connected to a session", "1": "Connecting...", "2": "Hosting", "3": "Connected", "4": "Connection failed", "5": "Seraching"};
|
||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
connectionState = ipcRenderer.sendSync("synchronous-message", "SESSION:get.state");
|
connectionState = ipcRenderer.sendSync("synchronous-message", "SESSION:get.state");
|
||||||
document.getElementById("sessionStateText").innerHTML = connectionStatesAsText[String(connectionState)];
|
document.getElementById("sessionStateText").innerHTML = connectionStatesAsText[String(connectionState)];
|
||||||
@@ -218,6 +218,9 @@
|
|||||||
<button onclick='createNewSession()'>
|
<button onclick='createNewSession()'>
|
||||||
Create new session
|
Create new session
|
||||||
</button>
|
</button>
|
||||||
|
<button onclick='ipcRenderer.sendSync("synchronous-message", "SESSION:startSearch");'>
|
||||||
|
Start session search
|
||||||
|
</button>
|
||||||
<script>
|
<script>
|
||||||
function createNewSession() {
|
function createNewSession() {
|
||||||
val = document.getElementById("sessionName").value
|
val = document.getElementById("sessionName").value
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Intel(R) I211 Gigabit Network Connection
|
Loopback Pseudo-Interface 1
|
||||||
Reference in New Issue
Block a user