Server Questions

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Server Questions

Post by Klaus » Sun Jan 10, 2016 1:51 pm

Hi A1Qicks,
A1Qicks wrote: get lChatterArray[s] ##Gives the username
find it in field "HelpMe"
delete it
avoid using IT more than once, since IT will change when you least exspect IT! :D

You last line will result in:
delete "the_username"
and that is just not enough for LC to do something meaningful with!

Try this:

Code: Select all

...
find lChatterArray[s] in fld "HelpMe"
if the result = "Not found" then
  exit to top
end if
delete the foundchunk
...
Hint: Always look in the dictionary (here: find) under "See also" (foundchunk etc...)!


Best

Klaus

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: Server Questions

Post by A1Qicks » Sun Jan 10, 2016 7:00 pm

Avoid "it" - got... the concept! :D
Klaus wrote:
Hint: Always look in the dictionary (here: find) under "See also" (foundchunk etc...)!
I do try to look at the dictionary, but often I don't know exactly what I'm meant to be looking for - foundchunk makes sense now that I see it, but amidst all the other stuff, not so clear.

Next up! I'm currently working on ways to send information through the socket that isn't just messages. Since I don't know any better way of doing it, I've got a system where the server sends a message that leads with an obscure set of letters and numbers and the client checks whether the incoming message starts with those, and if it does, it does something different with them:

if data contains "x110763User" then
ToOnlineList data
else

This is more or less functional so far, but I have two questions based on it:

1. Is there a better way of doing it that I don't know about?

2. How can I delete x110763User from the data before ToOnlineList? I just don't know the phrasing and the dictionary doesn't offer anything. I would have thought something like:

delete 11 characters of data

But that doesn't work. I just don't know the phrasing yet!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Server Questions

Post by Klaus » Sun Jan 10, 2016 8:00 pm

HI A1Qicks,

if this is always the case:
...whether the incoming message STARTS with those...
You can:

Code: Select all

...
if data BEGINS with "x110763User" then
  delete char 1 to length("x110763User") of data
  ToOnlineList data
else
...
Best

Klaus

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: Server Questions

Post by A1Qicks » Sun Jan 10, 2016 9:19 pm

Perfect! That works lovely...ly.

Thanks Klaus!

A1Qicks
Posts: 79
Joined: Sat Dec 26, 2015 10:47 am

Re: Server Questions

Post by A1Qicks » Tue Jan 12, 2016 2:32 pm

This is sort of a 'step backwards' question given I'm already fairly in deep with the server mechanics, but can anyone explain blocking vs. non-blocking to me? I keep reading it everywhere but can't quite get my head around it.

So:

read from socket pSocket with message "messageReceived"

is non-blocking. Which apparently means 'the read request will exit instantly'. But what does that mean? It reads what's sitting in the socket currently (like finding a letter on your doorstep) and then stops reading (like going back inside after getting the letter)?

Then:

read from socket pSocket

is blocking, "not returning until data has been received from the client. When data is received, the read command will return and the data will be placed in it."
I have to say I have no idea what this means. Does it mean you're waiting on the doorstep for the letter to arrive, and then you take it into the house afterwards?

I understand the fact that with a message, when it receives data it does the message, which means it can respond to data being received, but I don't understand blocking/non-blocking.

Can anyone clarify in slightly less arcane terms?

Post Reply