Recent

Author Topic: Is it possible to send message in users in database?  (Read 2457 times)

rdny

  • New Member
  • *
  • Posts: 38
Is it possible to send message in users in database?
« on: December 18, 2018, 03:02:29 am »
Is it possible to send message in users on database?  Like a messenger but Using only database. I'm not using any network components btw :D.

balazsszekely

  • Guest
Re: Is it possible to send message in users in database?
« Reply #1 on: December 18, 2018, 07:04:03 am »
Is it possible to send message in users on database?  Like a messenger but Using only database. I'm not using any network components btw :D.
Firebird has a feature called "Events", which is not available in other database management systems. Events are notification messages sent asynchronously from server to clients. If you're not a firebird user, just create a table("Messages" for example), with the following fields:

ID(integer) -->unique id
FROM_ID(integer) --> sender's id *
TO_ID(integer) --> receiver's id *
DATETIME(timestamp) --> when the message was sent
TEXT(varchar or blob)-->message text
STATUS(integer)-->message status(0 -> not received,  1-->received)
* I assume each user has an uniqiue id, if not you should redesing the database

When a user wish to send a message, just insert a new record into the table with the appropriate data.
From time to time, each client will fetch the table, if the client's id and "to_id" are the same, plus the message "status" is zero, display the message to the user, then change status to 1. You can move messages with status 1 to a history table to avoid bloating. 


rdny

  • New Member
  • *
  • Posts: 38
Re: Is it possible to send message in users in database?
« Reply #2 on: December 19, 2018, 12:37:45 am »
Is it possible to send message in users on database?  Like a messenger but Using only database. I'm not using any network components btw :D.
Firebird has a feature called "Events", which is not available in other database management systems. Events are notification messages sent asynchronously from server to clients. If you're not a firebird user, just create a table("Messages" for example), with the following fields:

ID(integer) -->unique id
FROM_ID(integer) --> sender's id *
TO_ID(integer) --> receiver's id *
DATETIME(timestamp) --> when the message was sent
TEXT(varchar or blob)-->message text
STATUS(integer)-->message status(0 -> not received,  1-->received)
* I assume each user has an uniqiue id, if not you should redesing the database

When a user wish to send a message, just insert a new record into the table with the appropriate data.
From time to time, each client will fetch the table, if the client's id and "to_id" are the same, plus the message "status" is zero, display the message to the user, then change status to 1. You can move messages with status 1 to a history table to avoid bloating.


Hi I understand but, how will I code it in Laz? Can you send me a sample? Sorry I'm a beginner in Pascal Programming. Thanks Getmem!  :D

balazsszekely

  • Guest
Re: Is it possible to send message in users in database?
« Reply #3 on: December 19, 2018, 01:47:30 pm »
Quote
Hi I understand but, how will I code it in Laz? Can you send me a sample? Sorry I'm a beginner in Pascal Programming.
I can help with the details, but unfortunately I don't have enough free time to code a full application.

rdny

  • New Member
  • *
  • Posts: 38
Re: Is it possible to send message in users in database?
« Reply #4 on: December 21, 2018, 02:27:35 am »
Quote
Hi I understand but, how will I code it in Laz? Can you send me a sample? Sorry I'm a beginner in Pascal Programming.
I can help with the details, but unfortunately I don't have enough free time to code a full application.


It's okay, I appreciated your help. Thanks! :D

incendio

  • Sr. Member
  • ****
  • Posts: 269
Re: Is it possible to send message in users in database?
« Reply #5 on: December 22, 2018, 03:29:39 am »
Never tried in Lazarus, but there is an IBEvent LCL, you should use this to monitor event raised in Firebird Database.

 

TinyPortal © 2005-2018