Прямая связь
Программирование на сокете - ваш друг. Это означает, что эти два приложения знают друг о друге, или по крайней мере одно из них (клиент) знает о другом (сервере)
C# пример прослушивателя tcp / ip
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net; //required
using System.Net.Sockets; //required
namespace ServerTest
{
class Program
{
static void Main(string[] args)
{
TcpListener server = new TcpListener(IPAddress.Any, 9999);
// we set our IP address as server's address, and we also set the port: 9999
server.Start(); // this will start the server
while (true) //we wait for a connection
{
TcpClient client = server.AcceptTcpClient(); //if a connection exists, the server will accept it
NetworkStream ns = client.GetStream(); //networkstream is used to send/receive messages
byte[] hello = new byte[100]; //any message must be serialized (converted to byte array)
hello = Encoding.Default.GetBytes("hello world"); //conversion string => byte array
ns.Write(hello, 0, hello.Length); //sending the message
while (client.Connected) //while the client is connected, we look for incoming messages
{
byte[] msg = new byte[1024]; //the messages arrive as byte array
ns.Read(msg, 0, msg.Length); //the same networkstream reads the message sent by the client
Console.WriteLine(encoder.GetString(msg).Trim('')); //now , we write the message as string
}
}
Создание API для общения
Варианты не ограничены. Создайте API для отдыха, используя WebApi 2 или любую другую технологию, чтобы периодически проверять наличие обновлений данных.
Это взаимодействие асинхронное, а не прямое, поэтому следует каким-то образом учитывать его.
Используйте pu sh уведомления
Мобильные приложения могут получать уведомления pu sh. Если сообщение не является двунаправленным, это само по себе может быть решением.
Если это так, то мобильное приложение может обмениваться данными через API, а приложение форм - с помощью уведомлений pu sh
Проверка https://gamedev.stackexchange.com/questions/157009/how-can-i-send-android-notifications-from-my-unity-game#