Come chat with me!
#1
Code: (Select All)
Dim Shared out$


Print "[Steve's Mini Messenger]"
client = _OpenClient("TCP/IP:7319:172.83.131.239") ' Attempt to connect to local host as a client
Print "[connected to " + _ConnectionAddress(client) + "]"

Input "Enter your name: ", myname$
out$ = myname$ + " connected!"
l = Len(out$)
Put #client, , l
Put #client, , out$
Do
    GetMessage client
    SendMessage myname$, mymessage$, client ' display current input on screen
    _Limit 30
Loop

'.................... END OF MAIN PROGRAM ................


Sub GetMessage (client) ' get & display any new message
    Get #client, , l
    If l > 0 Then
        _Delay .25
        out$ = Space$(l)
        Get #client, , out$
        View Print 1 To 20
        Locate 20, 1
        Print out$
        View Print 1 To 24
    Else
        out$ = ""
    End If
End Sub

Sub SendMessage (myname$, mymessage$, client) ' simple input handler
    k$ = InKey$
    If Len(k$) Then
        If k$ = Chr$(8) And Len(mymessage$) <> 0 Then
            mymessage$ = Left$(mymessage$, Len(mymessage$) - 1)
        Else
            If Len(k$) = 1 And Asc(k$) >= 32 Then mymessage$ = mymessage$ + k$
        End If
    End If
    View Print 1 To 24
    Locate 22, 1: Print Space$(80); ' erase previous message displayed
    Locate 22, 1: Print myname$ + ": "; mymessage$;
    If k$ = Chr$(13) Then ' [Enter] sends the message
        If mymessage$ = "" Then System ' [Enter] with no message ends program
        mymessage$ = myname$ + ":" + mymessage$
        l = Len(mymessage$)
        Put #client, , l
        Put #client, , mymessage$
        _Delay .25
        mymessage$ = ""
    End If
    If k$ = Chr$(27) Then System ' [Esc] key ends program
End Sub


There's been several folks who have been chatting and asking about TCP/IP communications between computers here lately, so I thought I'd showcase how it's done once again.

Above is a very simple client, which remotes out from your PC (you may have to open your firewall for it, or disable a few "protect yourself from yourself" settings, depending on your system), and which then connects to my laptop by which we can then chat happily with each other.

Feel free to hang around in the little chat all day with us, if you're able.  I'm going to keep the host up and going until after midnight EST for everyone, but that certainly doesn't mean I'm going to sit and hover over my laptop that whole time to always be available to instantly say, "HEY!  I SEE YOU!  CAN YOU HEAR ME NOW??"

The more folks who pop in and hang around, the more folks who can chatter with each other and welcome someone new into the channel, so they can be certain that the program is working and communicating in both directions for them.  

If all this works, without folks having too hard an issue running with it, I'll post the host and client both sometime tomorrow and then try and walk everyone through all the steps I went through to get it to play nicely with my router, firewall, and all.  Wink
Reply
#2
Smile 
Eventually they will come!

Creating an account with Discord looks like a complication for me at the moment. I have a "house" telephone only, no portable thing, but their authorization access expects me to have one of those silly slipper-looking things on me. I have been fighting with myself about joining Libera Chat somewhere. Considered it with this channel related to the forum I kicked myself out of a short time ago.

I added a few things to your program, so the "conversation" could be saved to a text file.
Reply
#3
Well guys, I'm heading out for a while to go get some lunch.  'Twas a pleasure chatting with everyone who's stopped in so far today, that I didn't miss.  Smile

Richard is still in the channel, as is issues32, and maybe a few other lurkers, so feel free to pop in and say "Howdy" to everyone, until I get back later.  As I mentioned in the first post, I'm going to leave the host open until after midnight tonight, even if I'm not going to spend 18 hours or so hovering over the keyboard that whole time.  LOL!

Feel free to stop in anytime today.  I can't always promise that there'll be a human on the other side of the channel to chat with, but at least there's the *chance*  that you'll get to meet and greet some of our forum members and chat with them via a 100% QB64-PE only program!  Big Grin
Reply
#4
F this messenger. I just got on to order a steak sandwich with large drink, and all I got back was a Tongue emoji!

Pete
Reply
#5
Arrow I was ezila_vermin.
Reply
#6
Thanks for chatting with me, Steve.  It will be fun building on this little messenger.  Hi mnrvovrfc, I wondered who that was.

I changed a couple lines to suit my taste, added a blinking cursor showing where I am typing, and also added a CLS in the view print area because long messages just didn't clear right for me.  Here it is in case others want to add it.  In the SendMessage SUB I edited the VIEW PRINT area code to this:

Code: (Select All)
VIEW PRINT 22 TO 24: CLS '<<< Added CLS to clear all
'LOCATE 22, 1: PRINT SPACE$(80); ' erase previous message displayed  '<<< not needed now
LOCATE 22, 1: PRINT myname$ + ": "; mymessage$;
IF INT(RND * 2) = 1 THEN PRINT "_"; ELSE PRINT " "; '<<< show a blinking cursor

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#7
(12-11-2022, 03:35 AM)Dav Wrote: I changed a couple lines to suit my taste, added a blinking cursor showing where I am typing, and also added a CLS in the view print area because long messages just didn't clear right for me.  Here it is in case others want to add it.  In the SendMessage SUB I edited the VIEW PRINT area code to this:
I desired to do that sort of thing but only left it to the third parameter of "LOCATE". At my side changed it so it added to a text file, saving text that I sent out and what I received from you guys, but my text was doubled up LOL. In the second time I jumped in, I guess somebody else replied and this program was trying to complete the process, which made it produce a couple of gibberish characters. Then later Pluma text editor refused to load the document. I had to go to the terminal in Manjaro MATE, open "nano" program to edit that file.

Too bad this program might not be useful anymore unless "security checks" are involved. If Steve doesn't want to be administrator anymore then we'll need somebody else to keep the show running. It's something he said (the last thing on the first post of this topic) which is not recommendable anymore. There are too many wicked people and a few others just want to show off by risking prosecution, but by making somebody else sad.
Reply




Users browsing this thread: 6 Guest(s)