Using TThread and creating message boards

Hello everyone. I have a few problems in Delphi that are giving me a lot of trouble. The first is using threads and the TThread component. I know what a TThread is supposed to do, but I am unsure of how to us it within my programs. If anyone could explain the component to me or give me a mini-tutorial of how to use it I would be most grateful.

Secondly, would it be possible to create message boards in Delphi? I've been trying to accomplish that using Tedit and Tmaskedit components but I haven't been getting very far. Once again, If anyone has any information I would be most grateful.

Thanks in Advance!

Aoshishinomori

Comments

  • [b][red]This message was edited by zibadian at 2004-4-4 22:8:22[/red][/b][hr]
    : Hello everyone. I have a few problems in Delphi that are giving me a lot of trouble. The first is using threads and the TThread component. I know what a TThread is supposed to do, but I am unsure of how to us it within my programs. If anyone could explain the component to me or give me a mini-tutorial of how to use it I would be most grateful.
    :
    : Secondly, would it be possible to create message boards in Delphi? I've been trying to accomplish that using Tedit and Tmaskedit components but I haven't been getting very far. Once again, If anyone has any information I would be most grateful.
    :
    : Thanks in Advance!
    :
    : Aoshishinomori
    :
    First of all a TThread isn't a component, but an object.
    The best way to design a new thread is to create a program without a UI and with a very specific task. This way you don't have to worry too much about thread synchonization. You must create a descendant of the TThread object, and write your code in the Execute, because that is a abstract method.
    There is a clear example in the standard Delphi Demos (%DelphiPath%DemosThreads).


    You can create a messageboard in Delphi, but you also need to look into computer-to-computer communication. A simple messageboard is nothing more than a collection of strings, which can be added to by users and read by them. This always involves two different "programs": a client and a server. I've quoted programs, because most messageboards (like this one) use a HTML-page as client program.
    The server needs to do several things:
    1 - Verify the identity of the users trying to log in
    2 - Retrieve the individual messages from the clients and store them
    3 - Send the board to the clients.

    The first thing is very important, because it makes your server a little secure from people trying to do your server-compupter harm. also this is necessary to control how many people are posting messages and who they are. Commonly used methods are username-password combinations or computer-id checks.
    The second thing is in general quite simple. The server gets a command to store a certain string on a board. Then it writes that string to disk and adds a reference to the board database. The implementation of this can be quite complex though, becuase you might want to encrypt or sign the message. Perhaps you want to check for certain content before accepting the message. The possibilities are endless.
    The last thing is again simple in theory. The server gets a request from a client to see the board, and as a response sends all the messages referenced in the board database (see above). The client is then responsible to show these to the user. And again you can make this more difficult by using encryption and signing, formatting the messages, adding other content than just strings, user-defined settings, etc.

    In the most basic form, I would use a read-only TMemo as board and a TEdit as message-editor. The memo can also double as storage (remember to save periodically). At the click of a button (or enter key) the contents of the edit are added to the memo lines. This shouldn't be too difficult to write. Now you have a 1-user messageboard.
    If you add computer-to-computer communication to that, and add the edit to the memos on both computers you have a very basic 2-user message board. This set-up works for a low number of computers (<100), but for more I would certainly write a special server program to send the messages around and start working on a way to secure the data/computers from hackers.

    I hope this helps you in creating your messageboard.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion