๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void UYourGameInstance::CheckIfServerIsOnline(FString ServerIP, FString ServerPort) | |
{ | |
/* First bind our OnServerCheckFinished function to PingResult. | |
* When we get any reply from UDP server PingResult will be called | |
* and when PingResult is called the binded method (OnServerCheckFinished) is also called. */ | |
PingReult.BindUObject(this, &UYourGameInstance::OnServerCheckFinished); | |
/* Our UDP server ip (public ip) and port we have to ping. | |
* Port should be the exact same port we defined on UDP server node.js file on EC2 server */ | |
const FString Address = FString::Printf(TEXT("%s:%d"), *ServerIP, ServerPort); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Icmp.h" | |
/* Delegate to bind our custom function when we receive a reply from our EC2 UDP server */ | |
FIcmpEchoResultDelegate PingReult; | |
/* Sends a UDP echo to the given server and waits for a reply */ | |
UFUNCTION(BlueprintCallable) | |
void CheckIfServerIsOnline(FString ServerPublicIP, FString ServerPort); | |
/* Delegate called when we get a reply from our EC2 UDP server */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// port to listen to | |
var PORT = xxxxx; // Change to your port number | |
// x's should be replaced with your EC2 private ip | |
var HOST = 'ip-xxx-xx-xx-xxx.your-region.compute.internal'; | |
// Load datagram module | |
var dgram = require('dgram'); | |
// Create a new instance of dgram socket |