Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
8d8b1194
Commit
8d8b1194
authored
Feb 11, 2012
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize and simplify client deletion
parent
79b98214
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
25 deletions
+17
-25
share/lua/intf/modules/host.lua
share/lua/intf/modules/host.lua
+17
-25
No files found.
share/lua/intf/modules/host.lua
View file @
8d8b1194
...
@@ -125,13 +125,13 @@ function host()
...
@@ -125,13 +125,13 @@ function host()
return
vlc
.
win
.
console_read
()
return
vlc
.
win
.
console_read
()
end
end
local
function
del_client
(
client
)
local
function
del_client
(
client
,
nostdioerror
)
--client:send("Cleaning up.\r\n")
if
client
.
type
==
client_type
.
stdio
then
if
client
.
type
==
client_type
.
stdio
then
if
not
nostdioerror
then
client
:
send
(
"Cannot delete stdin/stdout client.\n"
)
client
:
send
(
"Cannot delete stdin/stdout client.\n"
)
return
end
end
for
i
,
c
in
pairs
(
clients
)
do
elseif
clients
[
client
]
then
if
c
==
client
then
if
client
.
type
==
client_type
.
net
if
client
.
type
==
client_type
.
net
or
client
.
type
==
client_type
.
telnet
then
or
client
.
type
==
client_type
.
telnet
then
if
client
.
wfd
~=
client
.
rfd
then
if
client
.
wfd
~=
client
.
rfd
then
...
@@ -139,12 +139,11 @@ function host()
...
@@ -139,12 +139,11 @@ function host()
end
end
vlc
.
net
.
close
(
client
.
wfd
)
vlc
.
net
.
close
(
client
.
wfd
)
end
end
clients
[
i
]
=
nil
clients
[
client
]
=
nil
return
else
end
end
vlc
.
msg
.
err
(
"couldn't find client to remove."
)
vlc
.
msg
.
err
(
"couldn't find client to remove."
)
end
end
end
local
function
switch_status
(
client
,
s
)
local
function
switch_status
(
client
,
s
)
if
client
.
status
==
s
then
return
end
if
client
.
status
==
s
then
return
end
...
@@ -194,7 +193,7 @@ function host()
...
@@ -194,7 +193,7 @@ function host()
append
=
append
,
append
=
append
,
}
}
client
:
send
(
"VLC media player "
..
vlc
.
misc
.
version
()
..
"
\n
"
)
client
:
send
(
"VLC media player "
..
vlc
.
misc
.
version
()
..
"
\n
"
)
table.insert
(
clients
,
client
)
clients
[
client
]
=
client
client
:
switch_status
(
status
.
password
)
client
:
switch_status
(
status
.
password
)
end
end
...
@@ -282,7 +281,7 @@ function host()
...
@@ -282,7 +281,7 @@ function host()
if
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLERR
)
if
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLERR
)
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLHUP
)
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLHUP
)
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLNVAL
)
then
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLNVAL
)
then
del_client
(
client
)
client
:
del
(
)
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLOUT
)
then
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLOUT
)
then
table.insert
(
wclients
,
client
)
table.insert
(
wclients
,
client
)
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLIN
)
then
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLIN
)
then
...
@@ -319,14 +318,7 @@ function host()
...
@@ -319,14 +318,7 @@ function host()
local
function
destructor
(
h
)
local
function
destructor
(
h
)
for
_
,
client
in
pairs
(
clients
)
do
for
_
,
client
in
pairs
(
clients
)
do
--client:send("Cleaning up.")
client
:
del
(
true
)
if
client
.
type
==
client_type
.
net
or
client
.
type
==
client_type
.
telnet
then
if
client
.
wfd
~=
client
.
rfd
then
vlc
.
net
.
close
(
client
.
rfd
)
end
vlc
.
net
.
close
(
client
.
wfd
)
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment