mirror of
https://github.com/TheGreyDiamond/Enlight.git
synced 2025-07-17 20:33:48 +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 dgram = require("dgram");
|
||||
var server = dgram.createSocket("udp4");
|
||||
var client = dgram.createSocket("udp4");
|
||||
const express = require("express");
|
||||
const { time } = require("console");
|
||||
const { nanoid } = require("nanoid");
|
||||
@ -43,6 +44,7 @@ pageLookup["header"] = "header.html";
|
||||
// 2 Connected as host
|
||||
// 3 Connected as Client
|
||||
// 4 Connection failed
|
||||
// 5 Searching
|
||||
|
||||
var sessionState = -1;
|
||||
var sessionStateGoal = -1;
|
||||
@ -348,6 +350,25 @@ function init() {
|
||||
sessionState = 1;
|
||||
sessionStateGoal = 2;
|
||||
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 {
|
||||
event.returnValue = "ERR:UNKNOW_CMD";
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Go back</button>
|
||||
<state>Sessionstate: <state id = "sessionStateText">unknown</state></state>
|
||||
<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(){
|
||||
connectionState = ipcRenderer.sendSync("synchronous-message", "SESSION:get.state");
|
||||
document.getElementById("sessionStateText").innerHTML = connectionStatesAsText[String(connectionState)];
|
||||
@ -15,6 +15,9 @@
|
||||
<button onclick='createNewSession()'>
|
||||
Create new session
|
||||
</button>
|
||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "SESSION:startSearch");'>
|
||||
Start session search
|
||||
</button>
|
||||
<script>
|
||||
function createNewSession() {
|
||||
val = document.getElementById("sessionName").value
|
||||
|
@ -207,7 +207,7 @@
|
||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Go back</button>
|
||||
<state>Sessionstate: <state id = "sessionStateText">unknown</state></state>
|
||||
<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(){
|
||||
connectionState = ipcRenderer.sendSync("synchronous-message", "SESSION:get.state");
|
||||
document.getElementById("sessionStateText").innerHTML = connectionStatesAsText[String(connectionState)];
|
||||
@ -218,6 +218,9 @@
|
||||
<button onclick='createNewSession()'>
|
||||
Create new session
|
||||
</button>
|
||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "SESSION:startSearch");'>
|
||||
Start session search
|
||||
</button>
|
||||
<script>
|
||||
function createNewSession() {
|
||||
val = document.getElementById("sessionName").value
|
||||
|
@ -1 +1 @@
|
||||
Intel(R) I211 Gigabit Network Connection
|
||||
Loopback Pseudo-Interface 1
|
Reference in New Issue
Block a user