0:00:24
what is going on guys welcome to uh
0:00:29
another session the first session i'll
0:00:32
say of 2022 of bill breaking fakes
0:00:35
brought to you by the roll coders
0:00:38
yes that is us baby so
0:00:43
really hope you have had a really
0:00:44
fantastic celebrations out of ending the
0:00:49
2021 and i have set your
0:00:53
goals for 2022 i know
0:00:56
i have how about you tori have you got
0:01:02
oh yeah they were already set like
0:01:06
like i know what i'm doing like this
0:01:07
next two months for sure
0:01:09
oh look at that look at that
0:01:13
honestly it's easy dude it's easy it's
0:01:21
shout out to any employees who are
0:01:23
watching this stream
0:01:25
tori is an amazing dev
0:01:29
he's actually contributing a lot to this
0:01:32
open source project
0:01:34
which we are enhancing um
0:01:37
from the past few months so you just
0:01:40
it's been an exciting journey
0:01:45
just before we actually start the action
0:01:48
of coding i would play the
0:01:50
acknowledgement or of the country so
0:01:56
i begin today by acknowledging the
0:01:58
traditional custodians of the land on
0:02:01
which we gather today and pay my
0:02:03
respects to the elders past present and
0:02:05
future i extend their respect to
0:02:08
aboriginal and torres strait islander
0:02:14
wonderful that is all done
0:02:24
so i don't know if you guys
0:02:27
remember or not but uh what we were
0:02:29
doing is um we were trying to integrate
0:02:40
yeah well i'll say sam
0:02:44
not the template because that's the
0:02:46
written part as in the the coding part
0:02:49
so yes i have been actually working on
0:02:52
it in my free time as
0:02:55
well getting all the infrastructure as
0:02:59
done and dusted as well
0:03:10
let's give you guys a tour of what i
0:03:12
have been up to so far
0:03:16
by the way just said this this
0:03:19
disclaimer i haven't been able to get
0:03:22
working but i'm this close this close
0:03:31
let's get on to sharing the screen
0:03:37
do that one right cool
0:03:41
so hi hi cute jesse
0:04:06
since the last session in my spare time
0:04:11
uh did all these um requirements that we
0:04:17
connection from the websocket api to the
0:04:26
um so how i've actually done is
0:04:31
that by following some tutorials and
0:04:36
have you done um this connecting the
0:04:43
before tory as well
0:04:44
oh no absolutely no no
0:04:47
okay perfect looking forward to it
0:04:50
yeah yeah me too because
0:04:53
this is all a brand new
0:04:55
brand new knowledge for me as well as in
0:04:57
i'm learning applying
0:05:00
failing fixing learning applying paid
0:05:04
which is basically the name of the show
0:05:07
as well bring break and fix um okay so
0:05:13
explain you uh what i have been actually
0:05:20
so where do i start i'm
0:05:22
just thinking where should i start from
0:05:25
okay cool so i think the easiest way is
0:05:38
um so save this is our
0:05:53
i said this is our
0:05:55
client and this is our
0:06:04
is actually uh yeah
0:06:13
so what happens here is that um
0:06:21
when we try to connect
0:06:23
our our our client
0:06:29
websocket basically
0:06:53
there's something called a root
0:06:59
and what that does is it basically
0:07:15
this as in dollar sign request
0:07:24
when this is present in the websocket
0:07:33
whatever value is here in the json
0:07:54
that's here that should be
0:08:02
is this all making
0:08:04
sense until now or not
0:08:08
it makes sense to me
0:08:09
i think of it as as uh
0:08:15
there's like a reducer pattern in
0:08:19
encoding so like i think of the example
0:08:27
other state management
0:08:29
libraries you have this reducer and so
0:08:34
which they probably borrowed from
0:08:35
obviously like event i think they just
0:08:37
borrowed it from events but like yeah
0:08:39
you just have an action
0:08:41
yeah the action the action is is like
0:08:44
some label essentially and then when
0:08:46
your api receives it it reads that it
0:08:50
reads what action you're sending
0:08:52
so like right right yeah
0:08:56
i don't know i forgot what you have but
0:08:58
like in the example i've seen is like
0:09:00
you can call it send message
0:09:03
okay okay cool and then a lot and then
0:09:05
along with the action
0:09:07
you'll send data maybe
0:09:09
maybe you'll send data along with it
0:09:11
like the like the message data that
0:09:14
you want to send to
0:09:17
along with along with it
0:09:26
to the concept that you're talking about
0:09:29
you're absolutely right um i didn't know
0:09:32
about the reducing pattern but i've just
0:09:46
the only difference would be
0:09:50
this doesn't really have to be
0:09:53
action this could be basically anything
0:10:06
oh i i mean not in the not in the yaml
0:10:09
but what you call like in that key value
0:10:13
like what you call the value for the
0:10:16
right right yeah i i was gonna go there
0:10:21
please example i've called the value
0:10:27
so according to you what would
0:10:30
this be for um i think is connect one of
0:10:34
those like must-have
0:10:38
actions in the in the websocket api
0:10:43
so that one just connects that one just
0:10:45
triggers a lambda to connect the client
0:10:55
see the overall concept of this value
0:11:00
will be the action
0:11:03
as in if you want to have
0:11:08
websocket api will read this value and
0:11:15
present with the value as in
0:11:18
the lambda that's actually connecting
0:11:21
and if you do disconnect
0:11:26
then it will look for a lambda with uh
0:11:35
wherever the value is here it will
0:11:38
it will look for a
0:11:42
function that has this label
0:11:50
this is where i've gotten up to so
0:12:00
this is our lambda
0:12:03
by the way we really hit this
0:12:07
it was the job okay
0:12:13
conveys the meaning yeah
0:12:15
so say this is a lambda for
0:12:40
if you have a certain value here
0:12:55
if there isn't any lambda
0:13:04
api will send this request
0:13:07
straight to the default
0:13:15
label basically that's not connect or
0:13:17
disconnect will just automatically go to
0:13:23
we go to the default lambda yes
0:13:26
yes okay so if i had said
0:13:34
default if i had said
0:13:51
a lot that you you wouldn't just
0:13:53
destroy but you will
0:13:55
you will go to the default and basically
0:14:01
give an exception if i remember
0:14:03
correctly or give a kind of a meaningful
0:14:12
cool so uh have you uh kind of have i've
0:14:23
because this is a brand new concept for
0:14:27
i think you i think that that that
0:14:29
covers like how the api
0:14:32
websocket gateway works yeah yeah
0:14:37
now that that is out of the way so i'll
0:14:44
go to this code so this part is i will
0:14:49
uh the entire websocket here
0:14:54
and then i've also created a test route
0:14:59
because i wanted to test the lambda
0:15:13
functions so at the moment i'm just
0:15:17
connect handler function
0:15:22
want to take baby steps and make sure
0:15:26
and then i've also
0:15:38
api gateway and then this
0:15:42
lambda integration is um
0:15:49
lambda function here
0:15:53
all right hope that makes sense
0:15:57
when i look at the animal i'm like okay
0:16:06
i've at said hope that makes sense
0:16:09
because it's not working
0:16:12
at the moment good job man
0:16:17
this is this is rough for me like doing
0:16:19
the ammo isn't like wow
0:16:36
yeah so what we want to do now is
0:16:41
basically i'm going to deploy this
0:16:48
and we will figure out
0:16:51
what is working and what isn't
0:16:54
because the last time i
0:16:57
did it i was getting uh some kind of uh
0:17:08
i was still in the process to figure out
0:17:14
okay let's close this
0:17:30
yes so this is to test the websocket
0:17:35
scroll delete stack yeah i wanna delete
0:17:40
there we go that's deleted and now i
0:17:43
wanna deploy again
0:18:01
whoops where did i mess up
0:18:06
i've done it too quick
0:18:09
the delete is still in progress
0:18:19
yes the delete my friend is still in
0:18:24
oops it wasn't that one so i need that
0:18:28
one to come over there
0:18:37
a they're popular by themselves
0:18:42
cool so let's go to cloud formation
0:18:52
that's been deleted
0:18:54
so now if we try and create it again
0:19:13
it's just deploying at the moment
0:19:22
not bad man i'm just like um
0:19:29
for my interview like on the 12th and
0:19:33
like working on my own project and also
0:19:39
fur rules too but yeah it's like
0:19:45
oh fantastic man so is that the one with
0:19:51
uh yeah yeah i have uh that's on the
0:19:54
that's on the 12th
0:19:59
how's the prep going
0:20:01
i mean it's it's good like um
0:20:04
i i have somebody i have another
0:20:07
engineer who works at t-mobile
0:20:12
um and he's he's he's really helpful so
0:20:16
and he's also looking for a role too so
0:20:18
we like meet up like
0:20:21
like maybe once or twice a week and do
0:20:25
just like mock mock interviews on the
0:20:31
yeah like it's good a lot of a lot of
0:20:33
learning gets done for sure
0:20:37
that's pretty epic man it's really
0:20:42
someone who's as in
0:20:45
um in the same situation as yours and
0:20:50
you guys actually being
0:20:55
each other and that also keeps you
0:20:58
motivated but most of all
0:21:01
it keeps you in a really good practice
0:21:05
yeah yeah it's it's it's really it's
0:21:08
really really good um like um
0:21:11
i'm good with react and he's he's kind
0:21:14
of like learning more about react so i'm
0:21:16
a bit further along on that so i can
0:21:20
in that regard um and then he just
0:21:24
teaches me a lot of other
0:21:26
stuff about you know working on the team
0:21:28
there and then like yeah just like the
0:21:31
other interview aspects that are
0:21:33
non-technical that's really helpful too
0:21:36
and he has like this awesome radio voice
0:21:40
so wow yeah so i'm like i'm like you
0:21:43
must do so well in your interviews
0:21:47
your voice is just so smooth
0:21:58
has he done a conference
0:22:00
career shift as in from
0:22:02
some other profession to
0:22:10
he um he started as uh
0:22:17
i think if i remember correctly he
0:22:19
started as um it support at t-mobile for
0:22:23
like a long time and moved up there to
0:22:26
like a more i don't know senior level or
0:22:28
something and then
0:22:30
and then he learned like
0:22:33
this dog and then he
0:22:36
i'll talk later man this dog's gonna
0:22:38
annoy me i gotta kick it out of here all
0:22:51
deployed and everything has been done
0:22:55
what we're doing at the moment is uh
0:22:57
i've just enabled um the
0:23:02
logs and i've also
0:23:13
is actually using the lambda proxy
0:23:17
so that's been done and um
0:23:29
testing it well i've actually installed
0:23:36
npm package called
0:23:41
which um i'm assuming stands for
0:23:48
hyphen c is a short form for
0:23:52
hyphen hyphen connect
0:23:56
actually i'll just
0:24:06
this is basically what i have
0:24:11
test the websocket in the terminal
0:24:14
and it's basically a
0:24:17
care and the flag that i'm using
0:24:29
iphone iphone connect and then here i've
0:24:31
got my url as well which is over here
0:24:35
all right so let's
0:24:37
press enter and see what do we get good
0:24:48
five or two okay so basically is working
0:24:56
working as well if that makes sense
0:25:00
what do you think is what do you think
0:25:08
to be honest if it was a 500 then it
0:25:15
you can't found it
0:25:17
oh so it's in the lambda you think
0:25:24
gonna check because i purposely
0:25:41
like internal server error yeah yeah
0:25:49
so i need to check the time zone 959
0:25:53
yeah this is the one
0:25:54
let's see where did we go wrong
0:26:00
oh so the lambda execution has filled
0:26:03
with the status 200 okay
0:26:06
so the status is 200 which means it's an
0:26:15
due to a customer function
0:26:21
gonna actually copy and paste this into
0:26:26
let's see what do i get
0:26:33
customer function error
0:26:38
just pause that one
0:26:41
it looks like you that's in python
0:26:45
don't don't need then python
0:26:54
do you have a do you have a lambda
0:26:59
lambda connect i'm just actually good
0:27:03
that you point it out i'll make you sure
0:27:14
okay yeah it's there
0:27:17
what what's in the code if you
0:27:20
yeah i'll just show it to you
0:27:22
so this is oh hang on a minute
0:27:26
i can check my bs code too
0:27:32
i don't know if you've uploaded it
0:27:35
uh i haven't uploaded it yet
0:27:41
actually it's good that you pointed it
0:27:44
out because i think
0:27:48
when you pointed it out i might have
0:27:52
known the problem already
0:27:58
so basically i was
0:28:00
checking if this matches the
0:28:03
file num um file name
0:28:07
yeah that's all but that doesn't seem to
0:28:10
the problem so this is in my
0:28:15
so basically what so i've got this
0:28:19
uh code from a repo as well
0:28:22
as in from the one of the online sources
0:28:30
basically i'm i'm trying to get a socket
0:28:38
domain name stage and
0:28:40
connector is coming
0:28:47
and then this is the end point
0:28:55
right this is what happens if you
0:28:58
basically copy and um well not copy and
0:29:01
paste but manually
0:29:08
this is interesting
0:29:13
because i don't really have any domain
0:29:28
can is there a way to like
0:29:34
what if what if instead of
0:29:39
what if you just like returned it to
0:29:41
like a 200 with the message high just to
0:29:44
see if the lambda actually
0:29:47
if it finds the lambda or you you you
0:29:50
certainly it's like it finds that lambda
0:29:54
so what i actually did is
0:29:58
this is the actual
0:30:12
and it's sending this
0:30:17
so the but the does the event
0:30:23
the event object doesn't it always have
0:30:30
i don't i wouldn't i wouldn't know about
0:30:34
how about if we keep google googling
0:30:39
error because i'm pretty sure the area
0:30:41
that you pointed out in
0:30:44
something must have to change around
0:30:49
yeah i don't know i'm not that well
0:30:55
the lambdas and everything to be honest
0:30:59
all we're doing is
0:31:11
lambda execution failed for the state
0:31:16
the provided key does not match the
0:31:20
so i've got this error here
0:31:31
that's really helpful
0:31:35
all right i'm looking it up let's see if
0:31:36
i can find something
0:31:49
um it looks like it is related to well
0:31:52
according to this article it looks like
0:31:54
it might be related to websockets so
0:31:57
yeah cool so it's a long article hold on
0:32:07
code means the connection is gone
0:32:10
or isn't established yet depending on
0:32:15
um you may want to so i think it's
0:32:20
okay you cannot send a websocket message
0:32:23
via the management api
0:32:25
in the connect route
0:32:27
that needs to succeed before the socket
0:32:30
connection will amount allow messages to
0:32:33
you will get a 410 code meaning the
0:32:36
connection is gone or doesn't exist
0:32:39
so something's wrong with the connection
0:32:42
yeah you shall or obviously because if
0:32:47
connected then this
0:32:59
hang on oh right right this has logs
0:33:08
one so go on exception
0:33:13
massive code message gone status code
0:33:17
alright but what's the actual
0:33:23
error type going exception
0:33:26
looks like it did log that event object
0:33:37
i think the the second one from the top
0:33:40
for the info headers host
0:33:48
so does that have a
0:33:50
domain property yeah i'm just
0:33:55
checking that as you speak
0:33:57
because that's the first thing that came
0:33:59
into my mind that this
0:34:01
need to have everything that
0:34:03
we have over there
0:34:05
oh here we go yeah that
0:34:10
isn't this really the one
0:34:13
i'm just gonna confirm that is that the
0:34:18
ac yeah okay that is the one
0:34:29
and then the stage
0:34:41
have i said that properly the
0:34:47
yeah and stage yeah that's fine
0:34:51
what's connection connection id is there
0:34:56
l u here every every lambda should have
0:35:07
promising client max window okay that
0:35:10
shouldn't really matter
0:35:13
uh okay that's the date connect even
0:35:16
event type connect
0:35:31
that's okay unknown error
0:35:33
post to connection
0:35:35
are you trying to use a personal
0:35:37
connection inside the connect handler
0:35:41
the web topic connection is only created
0:35:48
oh okay the connect handler has reached
0:35:53
are you trying to post the message
0:35:58
are you trying to be honest
0:36:04
okay i think it just tried to
0:36:09
or i mean uh commented out sorry yeah
0:36:15
i think that's i think that's the
0:36:18
yeah that makes sense because the other
0:36:20
article i read said
0:36:23
like you're trying to send a message
0:36:25
before it connects and i was confused
0:36:27
because i didn't know what to do
0:36:29
right so i think that's what that four
0:36:31
tenant error is is that
0:36:33
it hasn't established a
0:36:35
a connection to the
0:36:37
websocket api server
0:36:40
before you can send a message
0:36:43
ah okay so it hasn't connected yet but
0:36:50
telling it that i don't care if you
0:36:53
connect it or not but i want you to send
0:37:00
it might it might work if that get
0:37:05
what's that get socket contacts thing
0:37:08
oh i never mind i don't think it's going
0:37:10
to work never mind forget it
0:37:12
i think that gets socket contacts
0:37:18
wait what does that do
0:37:20
so is basically just
0:37:24
getting their socket crimp
0:37:28
as an oh and then just names
0:37:34
why does is that is
0:37:42
uh into the event uh
0:37:45
request context and
0:37:47
then it initiates the
0:37:50
api game management on
0:37:58
which is from here and then he basically
0:38:01
send us sends the data
0:38:08
and then it returns the connection id
0:38:10
endpoint and the data that's sent as
0:38:15
yeah poster connection so is that get
0:38:18
socket contacts function
0:38:21
um is that is that what you need to
0:38:24
to be honest establishment
0:38:29
yeah to be honest i got that
0:38:32
code from the online blog so i'm
0:38:36
thinking that this
0:38:38
this part should be fine
0:38:42
and we don't even have to send it
0:38:46
because it's actually
0:38:48
creating an error into opposed to
0:38:50
connection if you see the
0:38:53
if you see the thing here
0:38:56
in the message as in
0:38:59
uh should not oppose to connection
0:39:04
connect handler which i was
0:39:09
so so basically for a connect
0:39:13
all you need is basically just the uh
0:39:17
uh empty lambda turning return uh status
0:39:20
200 to make a connection
0:39:25
that's what it seems is
0:39:32
all right so what i'm gonna do probably
0:39:35
is a way to send no yeah i'm gonna
0:39:39
basically comment this one out
0:39:42
i don't need this send anymore
0:39:46
get socket event yeah i need this one
0:39:50
but you can save that for your your
0:39:52
default handler right
0:39:57
all right let's try and check this one
0:40:10
i wonder if you can send a body in the
0:40:17
so i would assume you can
0:40:26
it doesn't cause anything to
0:40:32
like it might cost another 10 minutes of
0:40:44
know that oops we were wrong this
0:40:47
shouldn't be there
0:40:48
then we know that there is actually a
0:40:51
fact that it should not be there
0:40:54
because it actually
0:41:03
have i done some build yes i have so now
0:41:09
hopefully we can get this working in
0:41:16
move on to the disk
0:41:26
so in the in the in the future
0:41:28
implementation like the on connect
0:41:34
basically take the
0:41:36
the connected user and toss them in
0:41:40
dynamodb in the table to say is
0:41:46
and then as soon as the user disc
0:41:49
disconnects it will actually remove
0:41:55
in dynamodb completely
0:42:03
okay so this is oh my goodness you have
0:42:06
no idea how much fun
0:42:08
i'm having at the moment just
0:42:10
experimenting learning checking
0:42:15
me too man blowing things up i love this
0:42:20
right there we go cool so the moment of
0:42:26
i just deployed it but didn't have to do
0:42:28
that yeah cool so now i
0:42:31
just want to check if i have to set the
0:42:36
migration again on the
0:42:41
in the connect one yeah it
0:42:44
must be there all right cool so let's
0:42:47
try out and see what do we get
0:42:56
all right there we go oh sexy
0:43:04
good job zane nice job
0:43:08
you're the one who
0:43:11
out my copy and pasting error
0:43:25
right but did it print out any any any
0:43:30
thing over there i'm just curious now
0:43:35
let's have a look if it did
0:43:39
59 no this might not be it
0:43:54
uh now this one i was working on yes
0:43:59
today so this probably can
0:44:04
any chance you can send me the the web
0:44:10
there's a there's a nice
0:44:12
website called pi socket
0:44:16
yeah yeah i know about that
0:44:22
i want to see if it gives the body
0:44:25
ah all right i see
0:44:28
uh the console the
0:44:33
yeah websocket cap
0:44:38
um i'm just checking where was the
0:44:42
web socket yeah there we go
0:44:52
oh and i'll just copy and paste that one
0:44:55
into the private chat so you can have
0:45:06
yeah if you can do that that'd be
0:45:10
all right just want to check if they
0:45:17
so that didn't actually produce anything
0:45:20
which is interesting
0:45:21
i was hoping they will produce the logs
0:45:25
that we can have look at
0:45:29
it connected but i didn't i didn't see
0:45:31
the the body the connect
0:45:38
that's good then as long as it connects
0:45:41
that's exactly what we want
0:45:50
all right so how about if we contin
0:45:55
actually i'm not i'm not gonna
0:46:03
uncommend this i'll just
0:46:07
because we might need that
0:46:15
okay so if i do basic
0:46:23
so let's move on to the disk connects
0:46:37
i'm gonna try my best
0:46:39
to complete the dis
0:46:42
connect one in nine minutes
0:46:48
let's see if i can make it
0:46:51
oh which was that one
0:46:55
i think you can just copy the connect
0:47:00
like your connect function i think it's
0:47:04
i think it's i think it's in amazon the
0:47:07
api gateway is where it knows to
0:47:09
disconnect i don't think you have
0:47:13
i'm just kind of like
0:47:15
making stuff up to be honest guys
0:47:18
i assume that's the way it works is like
0:47:22
this connect end point and this
0:47:23
disconnect endpoint
0:47:28
like i said i'm just kind of missing it
0:47:29
yeah like that was based on my
0:47:32
my vague memory of the reading
0:47:35
ah right and the videos we watched you
0:47:38
know let's try that
0:47:40
actually because i really i'm really
0:47:42
curious if that is the case actually
0:47:46
so end point is that one request context
0:47:50
yeah cool status okay perfect
0:47:54
all right let's oh no no we would have
0:47:57
to make changes to our
0:48:01
lambda function uh
0:48:04
template yeah mo as well
0:48:09
connect so what if i just copy and paste
0:48:13
i would really not copy and paste it but
0:48:16
i really wanna see if this works
0:48:28
on connect this causes disconnect
0:48:34
configure yet api can disconnect
0:48:42
just connect this connect handler
0:48:46
and then function ref which would be
0:48:48
disconnect as well
0:48:55
oh okay let's try this
0:49:02
do this one as well i i'm not entirely
0:49:05
sure if this one as in how i'm doing at
0:49:08
the moment will work
0:49:10
but we'll find out if it does
0:49:26
right let's give this a shot
0:49:34
and see how much ever messed up
0:49:41
would be nothing it could be everything
0:49:55
got the dot i found the dog
0:50:04
anything interesting there
0:50:19
oh it says if authorization fails on
0:50:22
connect the connection will not be
0:50:24
established the client will receive a
0:50:26
401 or 403 response what did we get 410
0:50:43
right um this is not being able to
0:50:46
deploy so the reason is the tesla lambda
0:50:53
null values are not allowed in templates
0:50:56
where did i give null values
0:51:04
really i literally copied and pasted the
0:51:11
maybe it's the white's white space
0:51:15
it must be the white space
0:51:17
however if i do just
0:51:23
control p yeah format format
0:51:28
document there's no ah
0:51:34
what do some validate
0:51:41
and then template dot emo
0:51:55
all right again why
0:52:11
okay so this is valid
0:52:13
wait where am i messing up here
0:52:16
um oh so am i having two lambda
0:52:20
integration and that's why it's not
0:52:30
that guy on the block did
0:52:44
yeah it was this one i suppose
0:52:51
yeah i think it was this one that got
0:52:56
yeah it was this one basically
0:53:02
has he got the lambda authorization
0:53:10
connects roots so it's got one
0:53:12
tesla lambda into integration
0:53:16
oh so it's go only one
0:53:19
test lambda integration
0:53:21
because it's only testing one thing
0:53:24
there of obviously
0:53:26
would have only won
0:53:44
okay i need something else
0:53:48
which one which one is it this can send
0:53:58
you can delete parameter
0:54:05
on disconnect function
0:54:07
remove the record corresponding with the
0:54:10
specified connection id
0:54:22
um and then on connect
0:54:39
commands then you can do this
0:54:56
okay that this is kind of what we need
0:54:59
right so score sim
0:55:02
connect integration disconnect route
0:55:10
so it's called the route separate and
0:55:12
then the integration separate
0:55:18
and send russian integration
0:55:23
connection tape oh on permission on
0:55:28
okay this is gonna take a bit more time
0:55:32
it's not gonna happen in nine minutes
0:55:43
i'm confused now not by you
0:55:49
i'm reading about the the disconnect
0:55:52
yeah and i and i thought
0:55:55
like i could be wrong i gotta like watch
0:55:57
something again now but i thought that
0:56:00
it would just be as simple as you
0:56:02
execute that lambda and
0:56:05
naively thought that you would know how
0:56:08
to disconnect that client but if you
0:56:10
think about it like
0:56:11
of course that doesn't work because like
0:56:14
you don't know which connection to to
0:56:16
disconnect right ah
0:56:19
yeah yeah yeah true
0:56:22
so actually makes sense yeah and so i
0:56:25
was like oh yeah like of course that's
0:56:29
so the thing is the thing that the docs
0:56:32
say that's confusing me
0:56:36
so the websocket connection can be
0:56:38
closed by the server or by the client so
0:56:41
like you know they can
0:56:43
close it on their end or your your
0:56:46
serverless function or whatever close it
0:56:56
when the connection is already closed is
0:57:00
so it says the disconnect
0:57:03
lambda fires after they disconnect not
0:57:08
so like you don't use it to disconnect
0:57:12
the client from the websocket you use it
0:57:15
to do something like remove them from
0:57:17
your dynamodb table
0:57:23
here's the thing i don't understand like
0:57:25
it doesn't provide clear instructions on
0:57:27
how you actually disconnect a client
0:57:33
i don't i don't i don't know i'm like
0:57:36
should wouldn't that just be as in
0:57:39
deleting their connection
0:57:42
id from the database
0:57:52
because if you see here i i saw this
0:57:56
article earlier on
0:57:58
yeah and in that one it basically said
0:58:03
what we should be doing
0:58:17
function it inserts the connection id
0:58:22
from the request content um context to
0:58:24
the dynamodb table
0:58:27
so basically that tells that okay this
0:58:31
this client has been connected
0:58:34
and then on disconnect
0:58:36
function it removes
0:58:40
corresponding to their specified
0:58:42
connection id value
0:58:45
which i'm assuming that if
0:58:48
the connection idea has been removed
0:58:51
then obviously if uh they will lose
0:58:54
connection automatically
0:59:01
i think you don't need dynam like you
0:59:03
will use dynamodb yeah but i i think you
0:59:07
don't need dynamodb to keep track of
0:59:11
well you need it to keep track of who's
0:59:13
connected who's not connected yeah but
0:59:15
there should be another way where like
0:59:18
so like you use the command line tool to
0:59:21
connect to the websocket
0:59:24
right so there should be another way too
0:59:26
where you can like
0:59:28
call some endpoint on aws and disconnect
0:59:31
you without even using dynamodb you know
0:59:37
yes i know exactly what you're talking
0:59:41
so basically you don't really want to be
0:59:43
dependent on dynamodb
0:59:46
right because you may you may remove
0:59:49
that person from the
0:59:51
from dynamodb but that doesn't mean the
0:59:54
websocket connection is closed
1:00:01
yeah those are two different things so i
1:00:06
how do you kill someone's websocket
1:00:08
connection i mean if they if they close
1:00:11
their browser window i think the
1:00:13
connection's like terminated
1:00:16
i think the server sits there and waits
1:00:20
amount of time and then if it doesn't
1:00:22
hear like a ping from them then it
1:00:25
probably just like kills the connection
1:00:27
but there should be a way where
1:00:31
like you should be able on the server
1:00:33
side to terminate the connection too but
1:00:36
i just don't understand how you do it
1:00:39
that's the part i'm confused about i
1:00:44
yeah i think i totally understand what
1:00:50
these two processes
1:00:57
uh there should be a
1:01:00
one process for disconnect and then
1:01:02
another process to actually delete the
1:01:11
i'll probably have to research
1:01:14
as in where and if that exists because
1:01:21
it's a brand brand new thing
1:01:28
ask that okay how does this work i would
1:01:32
just go straight to google and say okay
1:01:35
let me find out for you yeah yeah well i
1:01:39
was disappointed i was i was thinking oh
1:01:42
i just called this lambda and it would
1:01:44
disconnect the client well obviously not
1:01:46
because the lambda doesn't know that
1:01:49
you're the same person who connected
1:01:53
like previously because it's not a it's
1:01:56
these lambdas are decoupled they're not
1:02:00
server app where everything's
1:02:03
you know 24 7. so too bad
1:02:10
the best part is that we got the
1:02:12
connection working so yeah that's that's
1:02:14
all looking fantastic
1:02:18
our both enthusiasm
1:02:20
of learning willing to fail and then
1:02:24
trying and eventually succeeding so
1:02:27
that's been fantastic
1:02:32
vent that's really good um
1:02:39
watching being a pleasure having you all
1:02:41
um and yeah wherever you are in the
1:02:45
world good afternoon good morning and
1:02:49
night in the case of melbourne
1:02:52
and in bali as well
1:02:57
do you think it's dark
1:02:59
perfect guys we'll see you tomorrow's
1:03:11
all right cheers guys have a good one
1:03:13
bye-bye have a good night thank you