Indy 10 Delphi 7 Server Send Msg on button click.

Ok i have looked a a million examples and blogs, and demo's ect... but no one can tell me why i cant have the server send data to the client on a button click. 

I can get the client to send data on button click, 
I can get the server to send data on aServerExecute, and aServerConnect
Both of wich are (AContext: TIdContext) where a button is (Sender: TObject), Iam guessing thats why it wont work as i would like, but I still have to belive there is a way?

This is what I have soo far for server.

type
 TClientinfo = class(TIdServerContext)
        public
            IP: String;
            cname: String;
            procedure SendResponse(const Clientname: String;
        const AResponse: String);
        end;

=============
BUTTON CLICK
+(note it gives error on the AContext part)+
=============
procedure TFmHost.BSendClick(Sender: TObject);
var
Context: TClientInfo;
begin
    context(AContext).SendResponse(context.cname,'button click worked')  ;
    ServerListbox.items.add('Me: '+EMsgBox.Text);
end;

============
SENDRESPONSE
============
procedure TClientInfo.SendResponse(const Clientname: String;
const AResponse: String);
    var
        Context: TClientInfo;
    begin
      if Context.cname = clientname then
        begin
            Context.Connection.IOHandler.WriteLn(AResponse);
        end;
    end;
end.

Thanks for any help
0
glen
12/15/2011 5:57:45 AM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

2 Replies
1178 Views

Similar Articles

[PageSpeed] 14

Am 15.12.2011 06:57, glen morse wrote:

> =============
> BUTTON CLICK
> +(note it gives error on the AContext part)+
> =============

Which error (message) does it give?

> procedure TFmHost.BSendClick(Sender: TObject);
> var
> Context: TClientInfo;
> begin
>      context(AContext).SendResponse(context.cname,'button click worked')  ;
>      ServerListbox.items.add('Me: '+EMsgBox.Text);
> end;


I guess you have stored the AContext value in the ServerConnect method.
But how and where is Context created in the BSendClick method?
In the first line, the Context object is not yet created (and CName is 
not assigned). Does it compile at all?

-- 
Michael Justin
0
Michael
12/15/2011 3:29:40 PM
glen wrote:

> Ok i have looked a a million examples and blogs, and demo's ect... but
> no one can tell me why i cant have the server send data to the client
> on a button click.

Because you are accessing the server-side connection the wrong way.  TIdTCPServer 
maintains multiple client connections, which are stored in its Contexts list. 
 From outside of the server's own events, you have to manually retreive the 
desired connection from that list before you can do anything with it.

> I can get the client to send data on button click,

Sure, because you are only dealing with a single connection on the client 
side, so you do not have to hunt around for it.

> This is what I have soo far for server.

Try this:

{code:delphi}
type
  TClientinfo = class(TIdServerContext)
  public
    IP: String;
    cname: String;
    procedure SendResponse(const AResponse: String);
  end;

procedure TFmHost.BSendClick(Sender: TObject);
var
  Context: TClientInfo;
  List: TList;
  I: Integer;
begin
  List := server.Contexts.LockList;
  try
    for I := 0 to List.Count-1 do
    begin
      Context := TClientInfo(List[I]);
      if (Context.cname = TheClientYouWant) then
      begin
        Context.SendResponse('button click worked');
        ServerListbox.Items.Add('Me: '+EMsgBox.Text);
        Break;
      end;
    end;
  finally
    server.Contexts.UnlockList;
  end;
end;

procedure TClientInfo.SendResponse(const AResponse: String);
begin
  Connection.IOHandler.WriteLn(AResponse);
end.
{code}

--
Remy Lebeau (TeamB)
0
Remy
12/15/2011 5:35:42 PM
Reply:

Similar Artilces:

Converting Delphi 2007 Indy 10.2.3 to Delphi 2009 Indy 10.5.5 [Edit]
Hello, I am currently attempting to port over a Delphi 2007 project that uses Indy 10.2.3 (very successfully) to Delphi 2009 and Indy 10.5.5 (I just got the latest development build this morning). I think I am running into an encoding issue, but am not sure. Specifically, IDHTTP with SSL calls an old CGI and the CGI returns a .zip file and I then save it to the disk. In 2007 and before this worked perfectly. In 2009, it is not. Here is the examples of the 2 different results (though cut way short in the post) I am getting back: 2007: 'PK'#3#4#$14#0#0#0#8#0'rLQ9žrPb€'#0...

delphi 7 Indy 9 and Indy 10
Hi, I can upgrade to indy 10 in delphi 7. But I have discover that indy 9 and Indy 10 have some different properties, so i had to change my old programs that were made in indy 9 to upgrade it to new version, but it is a long work. So I want to know if it is possible to install in the same delphi 7 both versions indy 10 and indy 9. I have tried to do it but i received a error message: Cannot load package 'IndySystem70'. It contains unit 'IdWinSock2', which is also contained in package 'Indy70'. Some can give me ideas or a link to read how to install both versions. Thanks in advance IVO <IVO OCHOA> wrote in message news:157696@forums.codegear.com... > I have discover that indy 9 and Indy 10 have some different properties Indy 9 and 10 are not compatible with each other at all. Indy 10 was a major re-write, and thus has different internal architectures than Indy 9 had. > So I want to know if it is possible to install in the same delphi > 7 both versions indy 10 and indy 9. Technically yes, but not easily. You would have to have both versions installed but disabled globally, and then enable one or the other (not both) on a per-project basis as needed. > I have tried to do it but i received a error message: > Cannot load package 'IndySystem70'. It contains unit 'IdWinSock2', > which is also contained in package 'Indy70'. You cannot have both versions active in ...

Delphi 7, INDY 10 and FastMM
Hi everybody, I installed a version from April 2010 of INDY 10. I use the latest version of FastMM4. I use Delphi 7 Enteprise. In the version of INDY 10 I used before I changed the units IdStack, IdThread and IDThread save to avoid memory leak messages from FastMM. After installing the new version of INDY10 I get the following errors: 1) I have to change the setting of the $G compiler option from OFF to ON. 2) After changing this I get an error that the another MemoryManager has been loaded and FastMM could not be used. Does anybody has an idea what has been changed and...

migrating from Delphi 6 With Indy 10 to XE7 with Indy 10
I updated the original Indy in D6 to version 10 several years ago. Now I want to migrate my application from D6 to XE7 and would like some feedback on the best route to take. I usually send data using readln and writeln statements. The data is typically XML format. Since migrating to XE7 will include potential unicode data what is the best approach to take when reading and writing data? Will writeln and readln work in these cases or should I be using a different strategy to send unicode data between the tidtcpclient and tidtcpserver applications? al wrote: > I usually send data ...

Delphi 7 & Indy 10
I just installed Indy 10 in D7 all went fine until I attempted to compile and install the Supercore. When compiling IndySuperCore70.dpk got an error in IdFiber.pas Undeclared Identifier IfTrue, lines 227,228 & 352 also IfNotAssigned line 453. Don't think I'll need this package just wanted to pass the info on. Thanks, Don "Don Patrick" <donpatrick@cox.net> wrote in message news:159323@forums.codegear.com... > I just installed Indy 10 in D7 all went fine until I attempted to > compile and install the Supercore. Do not bother with SuperCore. It has not been worked on in a long time, and is not up to date with Indy 10's current architectures. -- Remy Lebeau (TeamB) Thanks for the info really didn't need it anyways. "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:159449@forums.codegear.com... > Do not bother with SuperCore. It has not been worked on in a long time, and > is not up to date with Indy 10's current architectures. > Remy Lebeau (TeamB) Remy Lebeau (TeamB) wrote: >Do not bother with SuperCore. It has not been worked on in a long >time, and is not up to date with Indy 10's current architectures. Just curious, why is it still in indy (i haven't seen supercore compiling in years) Greetings, Marius "Marius ." <please@nospamhere.com> wrote in message news:161026@forums.codegear.com... > Just cu...

Delphi 7 Indy 10 HTTPS [Edit]
I have an old program I inherited that I'm required to maintain and Delphi is not a language I regularly use. From what I can see, the program uses an http proxy server to monitor pages as they are loaded into a browser control. Depending on the name and/or the content of the pages, the http proxy server does various tasks. All has been good up until now. The client wishes to now use https for their pages and I was wondering how can I get the http proxy server to be able to deal with https pages and keep the client happy. I did try to add an IdSSLIOHandlerSocketOpenSSL to the program ...

How to send mail by Indy and Gmail ? (Delphi 7)
How to send mail by Indy and Gmail ? (Delphi 7) Thank you very much . ^_^ > {quote:title=ICST ICST wrote:}{quote} > How to send mail by Indy and Gmail ? (Delphi 7) > > Thank you very much . ^_^ I test successfully. [code] // Send mail by Gmail // // Delphi 7 Test OK // // need OpenSSL for Delphi 7 // http://indy.fulgan.com/SSL/ // UnCompress OpenSSL file for Delphi 7, and get two files : libeay32.dll , ssleay32.dll // put them with Program togeter. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, XPMan, StdCtrls, IdMessage, IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP, IdBaseComponent, IdComponent, IdIOHandler, IdIOHandlerSocket, IdSSLOpenSSL; type TForm1 = class(TForm) Button1: TButton; // Standard Button2: TButton; // Standard edtRecipients: TEdit; // Standard edtCC: TEdit; // Standard edtBCC: TEdit; // Standard edtSubject: TEdit; // Standard cbxConfirmReading: TCheckBox; // Standard ListBox1: TListBox; // Standard cbxPriority: TComboBox; // Standard mmMessage: TMemo; // Standard XPManifest1: TXPManifest; // Win32 odAttachments: TOpenDialog; // Dialogs IdSMTP1: TIdSMTP; // Indy Clients IdMessage1: TIdMessage; // Indy Misc IdSSLIOHandlerSocket1: TI...

Delphi 7, INDY 10 and FastMM [2nd]
Hi everybody. I try to compile the latest INDY 10 snapshot with Delphi 7 Enterprise. I'm using also FastMM 494. If I activate the directive {$DEFINE USEFASTMM4} (in system, core and protocols) I'm not longer able to compile the packages for system and core. For system (IndySystem79.dpk) I get the following error: Need imported data reference ($G) to access "IsMultiThread" from unit FastMM4 For core (IndyCore70.dpk) I get the following error: IdThread.pas (601) Undeclared identitfier: "IndyRegisterExpectedMemoryLeak" I also activated the comp...

Delphi 7 to Delphi XE
Have been using Delphi 7 for many moons ( have got later versions but never upgraded to ) My first problem is: Component Palette. in XE it is a small toolbar docked in top right in Delphi 7 it gives a large view of all the components. I am struggling to be able to cope/access my components.in Delphi XE. Can I make the component pallette tool bar the same size as Delphi 7, or is there a fast way to view/choose all available components in XE, that I have not spotted yet? Kind Regards, Robert. Hi, What I know is that in Delphi 2010 and XE you can choose between t...

Delphi 7 to Delphi XE2
Hi, Still using that old workhorse, Delphi7, but am going to the conference in London hosted by Embarcadero on Delphi XE2. Although I would like to "move with the times" and am keen to get the UNICODE and 64-bit support offered by the latest IDEs, I confess to being more than a little scared about all the UNICODE/String/AnsiString and 32/64 bit issues I'm probably going to fall over. Anyone recently upgraded from Delphi7 to one of the latest Delphi IDEs? Thanks, Alain On 03/02/2012 08:55, Alain Dekker wrote: > Still using that old workhorse, Delphi7, but am going to the conference in > London hosted by Embarcadero on Delphi XE2. > > Although I would like to "move with the times" and am keen to get the > UNICODE and 64-bit support offered by the latest IDEs, I confess to being > more than a little scared about all the UNICODE/String/AnsiString and 32/64 > bit issues I'm probably going to fall over. Anyone recently upgraded from > Delphi7 to one of the latest Delphi IDEs? I recently upgraded a sizeable (Paradox) app from D3 to XE2 and was pleasantly surprised. About 20-30 hours once I understood how XE2 works. Andrew -- Andrew Gabb email: agabb@tpgi.com.au Adelaide, South Australia phone: +61 8 8342-1021 ----- Recently moved a lexicographic application from D2007 to XE2 with little pain. As you would imagine, it is heavily string-based, with much use of TStringLists, cuttin...

Delphi 2007 to Delphi 7
I've written a class in Delphi 2007 that is not supported in Delphi 7. What would be the best way to achive what I've done in Delphi 2007 in Delphi 7? Thanks, Tom type BondConstants = class { Bond Types } type BondType = record const TREASURY = 3; AGENCY = 0; CORP = 1; MUNI = 2; SBA = 5; MBS = 4; CMO = 6; end; { Day Count Methods } type DayCount = record const ACTUAL_360 = 2; ACTUAL_365 = 1; ACTUAL_ACTUAL = 1; d30_360 = 0; ...

Delphi XE2 - Indy 10
Dear folks As result of security issues one of the email services in NZ has changed the settings of their email server. It used to be port 25 and outgoing mail was SMTP.xtra.co.nz. The port is now 465 and outgoing mail is now send.xtra.co.nz. The client configuration requires authentication and a secure connection (SSL). The result is that my code to connect for everyone using that provider is now "busted". I have changed the port and outgoing host accordingly. And have set the IOHandler of idSMTP as IdSSLIOHandlerSocketOpenSSL1. With the Authtype as satSASL. I have als...

How Can I Send Email thru GMAIL Server in Delphi 7?
Hi everyone. I have Delphi 7 and the Indy components. I know that GMAIL uses ssl/tsl. I saw a posting from Marco Cantu on how to use Indy to send an email thru the gmail server. My exploration came to a screeching halt when I saw that the D7 Indy components don't have the same properties that Marco was using in his example. Does anybody have a code sample on how to send email thru this server in Delphi 7? Besides Indy, are there any third party tools that can be used for this purpose? On 2015/07/23 05:08 PM, Debbie Erickson wrote: > Hi everyone. I have Delphi 7 and the Indy co...

How Can I Send Email thru GMAIL Server in Delphi 7? #2
Hi everyone. I have Delphi 7 and the Indy components. I know that GMAIL uses ssl/tsl. I saw a posting from Marco Cantu on how to use Indy to send an email thru the gmail server. My exploration came to a screeching halt when I saw that the D7 Indy components don't have the same properties that Marco was using in his example. Does anybody have a code sample on how to send email thru this server in Delphi 7? Besides Indy, are there any third party tools that can be used for this purpose? at this site is a working application for Delphi 7 and the source code http://delphi.about.com...

Delphi XE2, Indy 10
Dear folks The following code is supposed to send a text string to a client that is listening on a set port and ip address. The connection works fine. The problem is that nothing seems to be sent. {code} function TFCSelectForm.SendNitroMessage(NitroRequest: String): String; var sStrm: TMemoryStream; begin try sStrm := TMemoryStream.Create; try sStrm.WriteBuffer(Pointer(NitroRequest)^,Length(NitroRequest)); // sStrm shows as () in the debugger IdTCPClient1.IOHandler.Write(sStrm, 0, False); sStrm.Position := 0; finally ...

I wrote an application and used cracked delphi 7, after i bought delphi 7
I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? "I embezzled some money from my employer, returned the funds, and then got it back as a bonus. Can I still be arrested?" Uhhh .... didn't you just confess to a crime? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? Is there any legalization rules of embarcadero products? > {quote:title=Ivan Ivanov wrote:}{quote} > > Is there any legalization rules of embarcadero products? What does the license agreement say? (I don't think I've ever seen a license agreement that has amnesty clauses written into it.) Why do you think you violated the license? Were you caught? Do you WANT to be caught? Do you WANT to be sued? Thanks David that you answer my question, my english is too poor, can you tell me where is written about amnesty in licence, thanks in advance Am 29.12.2011 19:22, schrieb Ivan Ivanov: > Thanks David that you answer my question, my english is too poor, can you tell me where is written about amnesty in licence, thanks in adv...

HOW TO INSTALL Indy 10.5.7 in Delphi 2007 IDe from * Tiburon.zip * distribu
Date 25/05/2010 By Davide Spano e-mail davide.spano@armfield.co.uk ********************************************************************************** HOW TO INSTALL Indy 10.5.7 in Delphi 2007 IDe from * Tiburon.zip * distribution ********************************************************************************** - 0 What version of Indy I have in my IDE? To find out.. Create a new VCL project with a form and drag whatever of the components that are in the IDE Indy tool palette section (TIdTCPClient or other) then right click and select About Internet Dir...

Migrating From Delphi 7 to Delphi 2010
We did not know which forum was the best for this question. We have been wanting to migrate from Delphi 7 to a later version for years but it appears to be a daunting task. We first looked at D2006 and that was a radical new world. We bought D2010 a couple of years ago and not done much with it because there are so many parts to our applications. We have done a few new applications in D2010 and they seem to work okay. D2010 has not been impressive, perhaps because of the strangeness compared to D7. Is is possible for us to do a phased sort of migration where we do a form at a time? ...

Delphi 2007 RTL in Delphi 7
I read somewhere that it is possible to use Delphi 2007's (or for that matter Delphi 2006's) RTL in Delphi 7 by just recompiling the source of RTL. Is this really possible? What are the benefits that we can derive using a higher version's RTL? TIA Yogi Yang Yogi Yang wrote: > I read somewhere that it is possible to use Delphi 2007's (or for > that matter Delphi 2006's) RTL in Delphi 7 by just recompiling the > source of RTL. If it actually compiles in Delphi 7, I guess it would be possible. OTOH, if one has Delphi 2007 already, I don't s...

Migrating from Delphi 7 to Delphi XE3
Hello, Its time to leave the old Delphi 7 and move to the new (but not the latest) XE3. I was wondering if there is a good book or reference to learn all new things XE3 added. Any suggestions? On 5/3/2013 10:17 PM, George Karatsiolis wrote: > Hello, Its time to leave the old Delphi 7 and move to the new (but not the latest) XE3. > I was wondering if there is a good book or reference to learn all new things XE3 added. Try this one for starters: http://tinyurl.com/cgsu243 Aside from that you really need to evaluate your application. XE3 is Unicode for example.... So her...

Using Delphi 7 and Delphi 2010
I had a project in Delphi 7. I worked on it in Delphi 2010. When I try to open the .dpr again in Delphi 7, the IDE toolbar widens across both monitors, and Delphi 7 locks up. It appears that Delphi 2010 modifies the .dpr in a way that makes Delphi 7 unable to open it again. All my forms & units appear to open fine in D7 after D2010, except for the warnings on the ExplicitHeight and ExplicitWidth properties being missing... I can easily recreate the .dpr, but is this expected behavior? Thanks. Tom Field wrote: > I had a project in Delphi 7. > > I worked o...

Delphi 7 to Delphi 2009 conversion
Hello group, What do I need to do to comile the following code in D2009. Compiler error after the Else E2010: Incompatible Types 'AnsiChar' and 'Char' if isUnicode then SearchHandle := FindFirstFilew( PWideChar( fn ), FindDataW ) else SearchHandle := FindFirstFile( PAnsiChar( Ansistring( fn ) ), FindDataA ); <<<<<compiler error in the above line >>>>>>>>>>> Regards, Bryan > What do I need to do to comile the following code in D2009. > Compiler error after the Else > E2010: Incompati...

Unofficial Delphi 7 updates
Anybody noticed, even tried this Enhanced Run Time library for Delphi ? It's a hack of the D7 RTL/VCL http://blog.synopse.info/post/2009/12/20/Enhanced-Run-Time-library-for-Delphi-7 It's very interesting and I'd like to know it's stability. Edwin Ye wrote: > Anybody noticed, even tried this Enhanced Run Time library for Delphi > ? It's a hack of the D7 RTL/VCL This library violates Delphi's license (redistributing of RTL/VCL source files is not allowed). The last post was deleted and I'm sure this one will be deleted, too. -- Andreas H...

Moving from Delphi 7 to Delphi 2007
Is there any compelling reason to move (quite a large project) from Delphi 7 to Delphi 2007? Specifically, is there better Vista/Win7/Win8 integration provided by Delphi 2007? (In the project I am already using a custom manifest file for Vista/Win7 etc.. and not the std XPMan component) Does 2007 add any new bugs to the scene? Thanks Rael Rael wrote: > Is there any compelling reason to move (quite a large project) from > Delphi 7 to Delphi 2007? If you are going to upgrade, why not upgrade to something newer? > In the project I am already using a custom man...

Web resources about - Indy 10 Delphi 7 Server Send Msg on button click. - embarcadero.delphi.winsock

Delphi - Wikipedia, the free encyclopedia
... an archaeological site and a modern town in Greece on the south-western spur of Mount Parnassus in the valley of Phocis . The site of Delphi ...

Delphi Automotive (@DelphiAuto) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Delphi Automotive @ DelphiAuto ...

Delphi Connect for Verizon on the App Store on iTunes
Get Delphi Connect for Verizon on the App Store. See screenshots and ratings, and read customer reviews.


Audi working with Delphi to develop autonomous car tech
Audi is developing an iPad-sized device that will pack all the necessary computing power for a self-driving car

Domestic firms eye Delphi
BizChina offers latest business and market information of China, online updates of 17 industries, investment guides, business events and industry ...

Verizon And Delphi Officially Launch Vehicle Diagnostics Service - $250 For The Module, $5 A Month On ...
If you're a car nut, a paranoid parent, or a small business owner looking to do a little, uh, company vehicle economy analysis, Verizon's teamed ...

Watch out Google: Delphi gives Ars a ride in its self-driving car
The automotive components maker gave Ars a preview ride around the neighborhood. MOUNTAIN VIEW, CA—On Thursday morning I met with Delphi at its ...

Official: Verizon's Vehicle Diagnostics by Delphi now on sale for $250
Filed under: Technology Partnering with Verizon Wireless, Delphi Automotive has released its Vehicle Diagnostics by Delphi product that allows ...

Delphi partners with WiTricity on automated wireless charging system
One could easily argue that parking between the white lines at any local hangout presents a challenge for some inexperienced drivers. So, why ...

Resources last updated: 3/8/2016 9:50:41 AM