WebSocket Invia File .NET

· Componenti

A partire da sgcWebSockets 4.4.8, WebSocket Protocol Files è supportati da sgcWebSockets .NET Library.

This protocol consente inviando file utilizzando binary WebSocket transport. It può gestire big file con a low memoria usage.

Features

Code Example 

To inviare a File a server, solo chiama il metodo SendFile di File Protocol e pass il completo FileName come argument.

The file ricevuto da server, essere salvato per impostazione predefinita in lo stesso directory dove è il server executable o in il Path impostare in il Files.SaveDirectory property. 

// ... Create Server
TsgcWebSocketServer oServer = new TsgcWebSocketServer();
TsgcWSPServer_Files oServer_Files = new TsgcWSPServer_Files();
oServer_Files.Server = oServer;
oServer.Host = "127.0.0.1";
oServer.Port = 8080;
// ... Create Client
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
oClient.URL = "ws://127.0.0.1:8080";
// ... Create Protocol
TsgcWSPClient_Files oClient_Files = new TsgcWSPClient_Files();
oClient_Files.Client = oClient;
// ... Start Server
oServer.Active = true;
// ... Connect client e Invia File
if oClient.Connect() then
  oClient_Files.SendFile("c:\Documents\yourfile.txt");