Max_name123 Posted March 3, 2019 Share Posted March 3, 2019 How to send a text message from ServerModule to all MainForm sessions? Quote Link to comment Share on other sites More sharing options...
albertovesx Posted March 3, 2019 Share Posted March 3, 2019 Maybe using https://github.com/winddriver/Delphi-Cross-Socket this. Quote Link to comment Share on other sites More sharing options...
andyhill Posted March 3, 2019 Share Posted March 3, 2019 The author says "SSL under non - Windows platform is unstable, please do not use it in production environment" Quote Link to comment Share on other sites More sharing options...
aristeo Posted March 4, 2019 Share Posted March 4, 2019 Use websockets . I use thia component https://www.esegece.com/ for sending messages from server to clients Quote Link to comment Share on other sites More sharing options...
hph Posted March 5, 2019 Share Posted March 5, 2019 This can help you: Quote Link to comment Share on other sites More sharing options...
Max_name123 Posted March 5, 2019 Author Share Posted March 5, 2019 12 hours ago, aristeo said: Use websockets . I use thia component https://www.esegece.com/ for sending messages from server to clients I downloaded and installed components, added folders to tools-options-library, threw on the form sgcWebSocketClient1: TsgcWebSocketClient; sgcWebSocketServer1: TsgcWebSocketServer; and errors fell in, the uses compiler swears at: sgcWebSocket_Classes, sgcWebSocket_Classes_Indy, sgcWebSocket_Server, sgcWebSocket, sgcWebSocket_Client; What to do mind I will not put! And another question, is it possible to poll data on a server, for example, in a timer? P.S. By the way, I cannot understand why UniGui does not have built-in methods for sending data between the server and sessions (( Quote Link to comment Share on other sites More sharing options...
hph Posted March 5, 2019 Share Posted March 5, 2019 Hi In attach a small example. As websocket server, use: <sgcWebSockets\Demos\ServerSentEvents> and disable this: procedure TfrmServer.pageMainHTMLTag(Sender: TObject; Tag: TTag; const TagString: string; TagParams: TStrings; var ReplaceText: string); begin // if TagString = 'port' then // ReplaceText := IntToStr(WSServer.Port) // else if TagString = 'host' then // ReplaceText := '127.0.0.1'; end; Add in UniServerModul.CustomFiles (file is not available in the example): files/sgcWebSockets.min.js Hope it helps webSocket.zip 1 Quote Link to comment Share on other sites More sharing options...
Ario.Paxaz Posted March 6, 2019 Share Posted March 6, 2019 Hi Quote Add in UniServerModul.CustomFiles (file is not available in the example): Please share it.I don't find it on the package or internet. Best Regards. Quote Link to comment Share on other sites More sharing options...
hph Posted March 6, 2019 Share Posted March 6, 2019 Hi It is a part of the offical esegece websocket package. You will find it in: \sgcWebSockets\resources\ Quote Link to comment Share on other sites More sharing options...
Ario.Paxaz Posted March 6, 2019 Share Posted March 6, 2019 Hi How to can access to message text by code in Delphi? and How to can set address in this line socket = new sgcWebSocket("ws://127.0.0.1:5420"); by Delphi ? I want set my server IP and read it from file. Best Regards. Quote Link to comment Share on other sites More sharing options...
albertovesx Posted March 6, 2019 Share Posted March 6, 2019 A.soltani, use a htmlframe Quote Link to comment Share on other sites More sharing options...
albertovesx Posted March 6, 2019 Share Posted March 6, 2019 you can get it from this example, the file is opensource /** * eventsource.js * Available under MIT License (MIT) * https://github.com/Yaffle/EventSource/ */ httpp://www.esegece.com:5414/sgcWebSockets.js Quote Link to comment Share on other sites More sharing options...
hph Posted March 7, 2019 Share Posted March 7, 2019 @A.soltani Meaby this helps: socket.on('message', function(evt){ document.getElementById('log').innerHTML = evt.message; ajaxRequest(MainForm.window, "_message",["msgStr=" + evt.message]); }); and this?: function start_sse(param) { socket = new sgcWebSocket(param); ... I have updated the example, hope it helps you ;-) webSocket.zip 1 Quote Link to comment Share on other sites More sharing options...
andyhill Posted March 8, 2019 Share Posted March 8, 2019 A quick test shows it fails on Mobile iPhoneX Quote Link to comment Share on other sites More sharing options...
hph Posted March 8, 2019 Share Posted March 8, 2019 Hi I tested it on iPad mini / iPad pro (under ios 9.3.5 / 12.1.4) also android (samsung): no problem! Are you shure, you have the right setup? Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted March 8, 2019 Share Posted March 8, 2019 Why you are trying extra kod? You can get session list in unigui. look in demos. Add a property to main form. text, number or record type or what you need. Write set procedure to this property. Write a sent message procedure. In this procedure has a loop for sessions. and set income param(s) to session's mainform's xxxx property. Thats all. This can be problem in just hyperserver. 'cos If I'm not wrong, can not get all session list in hyperserver, so can not sent message to all. But this can fix. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.