Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package perl-Dancer2-Plugin-WebSocket for 
openSUSE:Factory checked in at 2021-06-02 22:12:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Dancer2-Plugin-WebSocket (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Dancer2-Plugin-WebSocket.new.1898 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Dancer2-Plugin-WebSocket"

Wed Jun  2 22:12:13 2021 rev:2 rq:896827 version:0.3.1

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/perl-Dancer2-Plugin-WebSocket/perl-Dancer2-Plugin-WebSocket.changes
      2020-11-09 15:43:31.312922401 +0100
+++ 
/work/SRC/openSUSE:Factory/.perl-Dancer2-Plugin-WebSocket.new.1898/perl-Dancer2-Plugin-WebSocket.changes
    2021-06-02 22:12:39.108092036 +0200
@@ -1,0 +2,17 @@
+Mon May 31 03:06:33 UTC 2021 - Tina M??ller <[email protected]>
+
+- updated to 0.3.1
+   see /usr/share/doc/packages/perl-Dancer2-Plugin-WebSocket/Changes
+
+  0.3.1 2021-05-30
+   [BUG FIXES]
+   - Fixed pod errors as reported by CPANTS. (GH#7, Mohammad S Anwar)
+   [STATISTICS]
+   - code churn: 3 files changed, 55 insertions(+), 41 deletions(-)
+  0.3.0 2021-05-30
+   [ENHANCEMENTS]
+   - add login hook. (GH#8, Vladislav Kantor)
+   [STATISTICS]
+   - code churn: 10 files changed, 306 insertions(+), 39 deletions(-)
+
+-------------------------------------------------------------------

Old:
----
  Dancer2-Plugin-WebSocket-0.2.0.tar.gz

New:
----
  Dancer2-Plugin-WebSocket-0.3.1.tar.gz
  cpanspec.yml

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Dancer2-Plugin-WebSocket.spec ++++++
--- /var/tmp/diff_new_pack.7xZmuc/_old  2021-06-02 22:12:39.572090889 +0200
+++ /var/tmp/diff_new_pack.7xZmuc/_new  2021-06-02 22:12:39.576090878 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-Dancer2-Plugin-WebSocket
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -16,17 +16,16 @@
 #
 
 
+%define cpan_name Dancer2-Plugin-WebSocket
 Name:           perl-Dancer2-Plugin-WebSocket
-Version:        0.2.0
+Version:        0.3.1
 Release:        0
-%define cpan_name Dancer2-Plugin-WebSocket
 Summary:        Add a websocket interface to your Dancers app
 License:        Artistic-1.0 OR GPL-1.0-or-later
-Group:          Development/Libraries/Perl
 URL:            https://metacpan.org/release/%{cpan_name}
 Source0:        
https://cpan.metacpan.org/authors/id/Y/YA/YANICK/%{cpan_name}-%{version}.tar.gz
+Source1:        cpanspec.yml
 BuildArch:      noarch
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  perl
 BuildRequires:  perl-macros
 BuildRequires:  perl(Dancer2::Plugin)
@@ -56,12 +55,12 @@
 popular server fitting the bill.
 
 %prep
-%setup -q -n %{cpan_name}-%{version}
+%autosetup  -n %{cpan_name}-%{version}
 find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path 
"*/script/*" ! -name "configure" -print0 | xargs -0 chmod 644
 
 %build
 perl Makefile.PL INSTALLDIRS=vendor
-make %{?_smp_mflags}
+%make_build
 
 %check
 make test
@@ -72,7 +71,6 @@
 %perl_gen_filelist
 
 %files -f %{name}.files
-%defattr(-,root,root,755)
 %doc AUTHOR_PLEDGE Changes CODE_OF_CONDUCT.md CONTRIBUTORS doap.xml example 
README.mkdn
 %license LICENSE
 

++++++ Dancer2-Plugin-WebSocket-0.2.0.tar.gz -> 
Dancer2-Plugin-WebSocket-0.3.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/CODE_OF_CONDUCT.md 
new/Dancer2-Plugin-WebSocket-0.3.1/CODE_OF_CONDUCT.md
--- old/Dancer2-Plugin-WebSocket-0.2.0/CODE_OF_CONDUCT.md       2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/CODE_OF_CONDUCT.md       2021-05-30 
18:51:47.000000000 +0200
@@ -5,9 +5,9 @@
 In the interest of fostering an open and welcoming environment, we as
 contributors and maintainers pledge to making participation in our project and
 our community a harassment-free experience for everyone, regardless of age, 
body
-size, disability, ethnicity, gender identity and expression, level of 
experience,
-education, socio-economic status, nationality, personal appearance, race,
-religion, or sexual identity and orientation.
+size, disability, ethnicity, sex characteristics, gender identity and 
expression,
+level of experience, education, socio-economic status, nationality, personal
+appearance, race, religion, or sexual identity and orientation.
 
 ## Our Standards
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/CONTRIBUTORS 
new/Dancer2-Plugin-WebSocket-0.3.1/CONTRIBUTORS
--- old/Dancer2-Plugin-WebSocket-0.2.0/CONTRIBUTORS     2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/CONTRIBUTORS     2021-05-30 
18:51:47.000000000 +0200
@@ -8,6 +8,7 @@
 
     * Frank Schreiner
     * Mohammad S Anwar
+    * Vladislav Kantor
     * Yanick Champoux
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/Changes 
new/Dancer2-Plugin-WebSocket-0.3.1/Changes
--- old/Dancer2-Plugin-WebSocket-0.2.0/Changes  2019-07-17 00:28:44.000000000 
+0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/Changes  2021-05-30 18:51:47.000000000 
+0200
@@ -1,45 +1,59 @@
 Revision history for Dancer2-Plugin-WebSocket
 
+0.3.1 2021-05-30
+ [BUG FIXES]
+ - Fixed pod errors as reported by CPANTS. (GH#7, Mohammad S Anwar)
+
+ [STATISTICS]
+ - code churn: 3 files changed, 55 insertions(+), 41 deletions(-)
+
+0.3.0 2021-05-30
+ [ENHANCEMENTS]
+ - add login hook. (GH#8, Vladislav Kantor)
+
+ [STATISTICS]
+ - code churn: 10 files changed, 306 insertions(+), 39 deletions(-)
+
 0.2.0 2019-07-16
-  [ ENHANCEMENTS ]
-    - add keyword 'websocket_connections' (GH#6)
+ [ENHANCEMENTS]
+ - add keyword 'websocket_connections' (GH#6)
 
-  [ STATISTICS ]
-    - code churn: 9 files changed, 160 insertions(+), 51 deletions(-)
+ [STATISTICS]
+ - code churn: 9 files changed, 160 insertions(+), 51 deletions(-)
 
 0.1.3 2019-01-27
-  [ DOCUMENTATION ]
-    - Fixed minor typo in the pod. (GH#4, Mohammad S Anwar)
+ [DOCUMENTATION]
+ - Fixed minor typo in the pod. (GH#4, Mohammad S Anwar)
 
-  [ MISC ]
-    - TravisCI now installs recommended modules as well.
+ [MISC]
+ - TravisCI now installs recommended modules as well.
 
-  [ STATISTICS ]
-    - code churn: 4 files changed, 13 insertions(+), 6 deletions(-)
+ [STATISTICS]
+ - code churn: 4 files changed, 13 insertions(+), 6 deletions(-)
 
 0.1.2 2019-01-20
-  [ MISC ]
-    - Adds tests via Mojolicious and the awesome Joel Berger. (GH#2) see
-      
https://github.com/MojoliciousDotIO/mojolicious.io/blob/master/blog/2018/12/20/testing-dancer/websocket.t
+ [MISC]
+ - Adds tests via Mojolicious and the awesome Joel Berger. (GH#2) see
+   
https://github.com/MojoliciousDotIO/mojolicious.io/blob/master/blog/2018/12/20/testing-dancer/websocket.t
 
-  [ STATISTICS ]
-    - code churn: 7 files changed, 62 insertions(+), 7 deletions(-)
+ [STATISTICS]
+ - code churn: 7 files changed, 62 insertions(+), 7 deletions(-)
 
 0.1.1 2017-11-20
-  [ BUG FIXES ]
-    - change protocol to 'wss://' if request is secure. (Frank Schreiner,
-      GH#1)
+ [BUG FIXES]
+ - change protocol to 'wss://' if request is secure. (Frank Schreiner,
+   GH#1)
 
-  [ STATISTICS ]
-    - code churn: 3 files changed, 12 insertions(+), 3 deletions(-)
+ [STATISTICS]
+ - code churn: 3 files changed, 12 insertions(+), 3 deletions(-)
 
 0.1.0 2017-10-14
-  [ ENHANCEMENTS ]
-    - Use Moo::Role instead of Role::Tiny.
-    - Add channels for connection grouping.
+ [ENHANCEMENTS]
+ - Use Moo::Role instead of Role::Tiny.
+ - Add channels for connection grouping.
 
-  [ STATISTICS ]
-    - code churn: 8 files changed, 297 insertions(+), 19 deletions(-)
+ [STATISTICS]
+ - code churn: 8 files changed, 297 insertions(+), 19 deletions(-)
 
 0.0.1 2017-10-06
-  - First release.
+ - First release.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/INSTALL 
new/Dancer2-Plugin-WebSocket-0.3.1/INSTALL
--- old/Dancer2-Plugin-WebSocket-0.2.0/INSTALL  2019-07-17 00:28:44.000000000 
+0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/INSTALL  2021-05-30 18:51:47.000000000 
+0200
@@ -8,10 +8,10 @@
 
     % cpanm Dancer2::Plugin::WebSocket
 
-If you are installing into a system-wide directory, you may need to pass the
-"-S" flag to cpanm, which uses sudo to install the module:
-
-    % cpanm -S Dancer2::Plugin::WebSocket
+If it does not have permission to install modules to the current perl, cpanm
+will automatically set up and install to a local::lib in your home directory.
+See the local::lib documentation (https://metacpan.org/pod/local::lib) for
+details on enabling it in your environment.
 
 ## Installing with the CPAN shell
 
@@ -22,7 +22,7 @@
 ## Manual installation
 
 As a last resort, you can manually install it. Download the tarball, untar it,
-then build it:
+install configure prerequisites (see below), then build it:
 
     % perl Makefile.PL
     % make && make test
@@ -31,13 +31,42 @@
 
     % make install
 
-If you are installing into a system-wide directory, you may need to run:
+On Windows platforms, you should use `dmake` or `nmake`, instead of `make`.
+
+If your perl is system-managed, you can create a local::lib in your home
+directory to install modules to. For details, see the local::lib documentation:
+https://metacpan.org/pod/local::lib
+
+The prerequisites of this distribution will also have to be installed 
manually. The
+prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` 
generated
+by running the manual build process described above.
+
+## Configure Prerequisites
+
+This distribution requires other modules to be installed before this
+distribution's installer can be run.  They can be found under the
+"configure_requires" key of META.yml or the
+"{prereqs}{configure}{requires}" key of META.json.
 
-    % sudo make install
+## Other Prerequisites
+
+This distribution may require additional modules to be installed after running
+Makefile.PL.
+Look for prerequisites in the following phases:
+
+* to run make, PHASE = build
+* to use the module code itself, PHASE = runtime
+* to run tests, PHASE = test
+
+They can all be found in the "PHASE_requires" key of MYMETA.yml or the
+"{prereqs}{PHASE}{requires}" key of MYMETA.json.
 
 ## Documentation
 
 Dancer2-Plugin-WebSocket documentation is available as POD.
-You can run perldoc from a shell to read the documentation:
+You can run `perldoc` from a shell to read the documentation:
 
     % perldoc Dancer2::Plugin::WebSocket
+
+For more information on installing Perl modules via CPAN, please see:
+https://www.cpan.org/modules/INSTALL.html
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/LICENSE 
new/Dancer2-Plugin-WebSocket-0.3.1/LICENSE
--- old/Dancer2-Plugin-WebSocket-0.2.0/LICENSE  2019-07-17 00:28:44.000000000 
+0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/LICENSE  2021-05-30 18:51:47.000000000 
+0200
@@ -1,4 +1,4 @@
-This software is copyright (c) 2019, 2017 by Yanick Champoux.
+This software is copyright (c) 2021, 2019, 2017 by Yanick Champoux.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
@@ -12,7 +12,7 @@
 
 --- The GNU General Public License, Version 1, February 1989 ---
 
-This software is Copyright (c) 2019, 2017 by Yanick Champoux.
+This software is Copyright (c) 2021, 2019, 2017 by Yanick Champoux.
 
 This is free software, licensed under:
 
@@ -272,7 +272,7 @@
 
 --- The Artistic License 1.0 ---
 
-This software is Copyright (c) 2019, 2017 by Yanick Champoux.
+This software is Copyright (c) 2021, 2019, 2017 by Yanick Champoux.
 
 This is free software, licensed under:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/MANIFEST 
new/Dancer2-Plugin-WebSocket-0.3.1/MANIFEST
--- old/Dancer2-Plugin-WebSocket-0.2.0/MANIFEST 2019-07-17 00:28:44.000000000 
+0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/MANIFEST 2021-05-30 18:51:47.000000000 
+0200
@@ -14,6 +14,10 @@
 cpanfile
 dist.ini
 doap.xml
+example-login/bin/app.psgi
+example-login/client/websocket-client-login.pl
+example-login/config.yml
+example-login/lib/MyApp.pm
 example/bin/app.psgi
 example/config.yml
 example/lib/MyApp.pm
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/META.json 
new/Dancer2-Plugin-WebSocket-0.3.1/META.json
--- old/Dancer2-Plugin-WebSocket-0.2.0/META.json        2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/META.json        2021-05-30 
18:51:47.000000000 +0200
@@ -4,7 +4,7 @@
       "Yanick Champoux <[email protected]>"
    ],
    "dynamic_config" : 0,
-   "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 
2.150010",
+   "generated_by" : "Dist::Zilla version 6.017, CPAN::Meta::Converter version 
2.150010",
    "license" : [
       "perl_5"
    ],
@@ -61,15 +61,15 @@
    "provides" : {
       "Dancer2::Plugin::WebSocket" : {
          "file" : "lib/Dancer2/Plugin/WebSocket.pm",
-         "version" : "v0.2.0"
+         "version" : "v0.3.1"
       },
       "Dancer2::Plugin::WebSocket::Connection" : {
          "file" : "lib/Dancer2/Plugin/WebSocket/Connection.pm",
-         "version" : "v0.2.0"
+         "version" : "v0.3.1"
       },
       "Dancer2::Plugin::WebSocket::Group" : {
          "file" : "lib/Dancer2/Plugin/WebSocket/Group.pm",
-         "version" : "v0.2.0"
+         "version" : "v0.3.1"
       }
    },
    "release_status" : "stable",
@@ -84,20 +84,22 @@
          "web" : "https://github.com/yanick/Dancer2-Plugin-WebSocket";
       }
    },
-   "version" : "0.2.0",
+   "version" : "0.3.1",
    "x_author_pledge" : {
       "version" : 1
    },
    "x_authority" : "cpan:YANICK",
    "x_contributor_covenant" : {
-      "version" : 0.01
+      "version" : 0.02
    },
    "x_contributors" : [
       "Frank Schreiner <[email protected]>",
       "Mohammad S Anwar <[email protected]>",
+      "Vladislav Kantor <[email protected]>",
       "Yanick Champoux <[email protected]>"
    ],
-   "x_generated_by_perl" : "v5.20.2",
-   "x_serialization_backend" : "Cpanel::JSON::XS version 3.0115"
+   "x_generated_by_perl" : "v5.30.0",
+   "x_serialization_backend" : "Cpanel::JSON::XS version 4.12",
+   "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later"
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/META.yml 
new/Dancer2-Plugin-WebSocket-0.3.1/META.yml
--- old/Dancer2-Plugin-WebSocket-0.2.0/META.yml 2019-07-17 00:28:44.000000000 
+0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/META.yml 2021-05-30 18:51:47.000000000 
+0200
@@ -12,7 +12,7 @@
 configure_requires:
   ExtUtils::MakeMaker: '0'
 dynamic_config: 0
-generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 
2.150010'
+generated_by: 'Dist::Zilla version 6.017, CPAN::Meta::Converter version 
2.150010'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -21,13 +21,13 @@
 provides:
   Dancer2::Plugin::WebSocket:
     file: lib/Dancer2/Plugin/WebSocket.pm
-    version: v0.2.0
+    version: v0.3.1
   Dancer2::Plugin::WebSocket::Connection:
     file: lib/Dancer2/Plugin/WebSocket/Connection.pm
-    version: v0.2.0
+    version: v0.3.1
   Dancer2::Plugin::WebSocket::Group:
     file: lib/Dancer2/Plugin/WebSocket/Group.pm
-    version: v0.2.0
+    version: v0.3.1
 requires:
   Dancer2::Plugin: '0'
   JSON::MaybeXS: '0'
@@ -44,15 +44,17 @@
   bugtracker: https://github.com/yanick/Dancer2-Plugin-WebSocket/issues
   homepage: https://github.com/yanick/Dancer2-Plugin-WebSocket
   repository: https://github.com/yanick/Dancer2-Plugin-WebSocket.git
-version: 0.2.0
+version: 0.3.1
 x_author_pledge:
   version: 1
 x_authority: cpan:YANICK
 x_contributor_covenant:
-  version: 0.01
+  version: 0.02
 x_contributors:
   - 'Frank Schreiner <[email protected]>'
   - 'Mohammad S Anwar <[email protected]>'
+  - 'Vladislav Kantor <[email protected]>'
   - 'Yanick Champoux <[email protected]>'
-x_generated_by_perl: v5.20.2
-x_serialization_backend: 'YAML::Tiny version 1.67'
+x_generated_by_perl: v5.30.0
+x_serialization_backend: 'YAML::Tiny version 1.73'
+x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/Makefile.PL 
new/Dancer2-Plugin-WebSocket-0.3.1/Makefile.PL
--- old/Dancer2-Plugin-WebSocket-0.2.0/Makefile.PL      2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/Makefile.PL      2021-05-30 
18:51:47.000000000 +0200
@@ -1,4 +1,4 @@
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker 
v6.012.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker 
v6.017.
 use strict;
 use warnings;
 
@@ -36,7 +36,7 @@
     "Test::More" => 0,
     "Test::Requires" => 0
   },
-  "VERSION" => "0.2.0",
+  "VERSION" => "0.3.1",
   "test" => {
     "TESTS" => "t/*.t"
   }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/README.mkdn 
new/Dancer2-Plugin-WebSocket-0.3.1/README.mkdn
--- old/Dancer2-Plugin-WebSocket-0.2.0/README.mkdn      2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/README.mkdn      2021-05-30 
18:51:47.000000000 +0200
@@ -4,7 +4,7 @@
 
 # VERSION
 
-version 0.2.0
+version 0.3.1
 
 # SYNOPSIS
 
@@ -36,6 +36,7 @@
     WebSocket:
         # default values
         serializer: 0
+        login: 0
         mount_path: /ws
 ```
 
@@ -147,6 +148,44 @@
 object and the Plack
 `$env` hash as arguments.
 
+## websocket\_on\_login sub { ... }
+
+```perl
+websocket_on_login sub {
+    my( $conn, $env ) = @_;
+    ...;
+};
+```
+
+Code invoked when a new socket is opened. Gets the
+connection object and the Plack `$env` hash as arguments.
+
+Example: return true if user is logged in and the webapp http\_cookie is the 
same as the websocket.
+
+```perl
+my $login_conn;
+my $cookie_name = 'example.session';
+
+hook before => sub {
+    if (defined cookies->{$cookie_name}) {
+        $login_conn->{'cookie_id'} = cookies->{$cookie_name}->value;
+    }
+    $login_conn->{'login'} = logged_in_user ? 1 : 0;
+};
+
+websocket_on_login sub {
+    my( $conn, $env ) = @_;
+
+    my ($cookie_id) = ($env->{'HTTP_COOKIE'} =~ /$cookie_name=(.*);?/g);
+    if (($login_conn->{'login'}) and ($login_conn->{'cookie_id'} eq 
$cookie_id)) {
+        return 1;
+    } else {
+        warn "require login";
+        return 0;
+    }
+};
+```
+
 ## websocket\_on\_close sub { ... }
 
 ```perl
@@ -260,7 +299,7 @@
 
 # COPYRIGHT AND LICENSE
 
-This software is copyright (c) 2019, 2017 by Yanick Champoux.
+This software is copyright (c) 2021, 2019, 2017 by Yanick Champoux.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/SIGNATURE 
new/Dancer2-Plugin-WebSocket-0.3.1/SIGNATURE
--- old/Dancer2-Plugin-WebSocket-0.2.0/SIGNATURE        2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/SIGNATURE        2021-05-30 
18:51:47.000000000 +0200
@@ -1,5 +1,5 @@
 This file contains message digests of all files listed in MANIFEST,
-signed via the Module::Signature module, version 0.79.
+signed via the Module::Signature module, version 0.83.
 
 To verify the content in this distribution, first make sure you have
 Module::Signature installed, then type:
@@ -14,35 +14,39 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 7a922e2f49d5f7ec6969bda8e0716f0c50c0cb64 AUTHOR_PLEDGE
-SHA1 dc51cae02a67955fe2ced58ef55493e147c48e84 CODE_OF_CONDUCT.md
-SHA1 1a07b44d0b4ee5258a2ae552f29a90c33ffdc1be CONTRIBUTORS
-SHA1 d9b1bfab958c6a3e7ba68825b2139038430702a1 Changes
-SHA1 d90805f0c95a92d1e14e824ced50a6eab7084c34 INSTALL
-SHA1 e4c10ea4d0ff6755d3f87ab3f5b113d625978ba3 LICENSE
-SHA1 c06f60770b94aa5c17a90b9aaccd72538b7cdbdb MANIFEST
-SHA1 2477645950ead421b63d2643f8efaed2cfa47cfd MANIFEST.SKIP
-SHA1 99e1ab19b25892f553f7a628bc0e4ff8d3a97faa META.json
-SHA1 16005d64a8eeb3cd1985770349ee62c5039cf292 META.yml
-SHA1 f9156b3add3bd2e39279c87a71f77f8573cba0b7 Makefile.PL
-SHA1 5ee372aa2092323cb33dc864ff832430236f9e88 README.mkdn
-SHA1 2fea80cbe81b8047be64f28b7e7d90227eec8e3a cpanfile
-SHA1 0ad7cb4ec6532864596767231e028973a6428df6 dist.ini
-SHA1 8052875544715c444105405059bd7bac0912e79f doap.xml
-SHA1 8f0ce66fbc8d9cbb18ab58814347efc1bd2f15c7 example/bin/app.psgi
-SHA1 f42d717595f98ac2d0ddd446cf3b8d4078b574ba example/config.yml
-SHA1 5d217a3e30fbba896dbb043c73afbae33e453b9e example/lib/MyApp.pm
-SHA1 b175b2becc4640e46f9d75ebf7f1fa053ea9b236 lib/Dancer2/Plugin/WebSocket.pm
-SHA1 f2588ad76b9930e7a1eb63340be06e33270ea08e 
lib/Dancer2/Plugin/WebSocket/Connection.pm
-SHA1 deb4eea73dd974c6db7fee9e868990f89cfb5cfd 
lib/Dancer2/Plugin/WebSocket/Group.pm
-SHA1 6cbf295cbd81783ccd7831621c12fe5d61485b1a t/00-compile.t
-SHA1 481fe4c3e4b18d2a10c73d8abef3dbbef26f4d6b t/00-report-prereqs.dd
-SHA1 6348689eee69681210251892bd47cbfbb7507d7d t/00-report-prereqs.t
-SHA1 d544a10f1356825a8a314723b1da1ff4d886719a t/example.t
-SHA1 d1fe7d94b3edc7847eb187d4ee41f66e19cf8907 xt/release/unused-vars.t
+SHA256 a03f6c61a49a7ef1cf30b5c4ba5eab282e1cff7a1ba214b6533dd3295988e175 
AUTHOR_PLEDGE
+SHA256 ce0736394bf7b9bdf342fc8856b96efbde75e2a9c2b8ed91868daf5410688e4e 
CODE_OF_CONDUCT.md
+SHA256 001e7b96d60446f9e722f2989872f6f2c500bfdc9691db064d0cc722d35e527a 
CONTRIBUTORS
+SHA256 73bed726584eea2d4352e9552d466a261ab056b1ef2d7d9cede10e69807eb7a9 Changes
+SHA256 4e8e7785fc5915baed9a18de78249afe7874ee64efe7a98bf7a07715e73ef5c1 INSTALL
+SHA256 3f086f6ef976038035188820df449e3150363bf991a3b0769da7c2105acb83f4 LICENSE
+SHA256 3d2c8cbf3ec81227c8d46d034df9e0ed84e1b3f29b9297f005e3aa5f8553fc40 
MANIFEST
+SHA256 8fdba02ac60a282c3c6fff6e48e05f9fba6ae92e370d900f927026571cb214aa 
MANIFEST.SKIP
+SHA256 3649569c05f2ee51886b10839f34e17d5d7bfc59974380e9a931017ffdbad598 
META.json
+SHA256 efd7feba5f64462e6c1975ec4fe95d7f9c033781791bafc663fdd0da66ae4b1c 
META.yml
+SHA256 f39244e07ed24bb96834d1e39cfa89ae90e99dd35e3e27a968727cee914976fb 
Makefile.PL
+SHA256 c6ef2de555f1b9f4caba6bd17c202752822bc3fcb4a84a307a945b2a6ff0b690 
README.mkdn
+SHA256 881d7951817fc0710343065a8408a9a0e33c462ac02405efb6d63ae2e47e07fc 
cpanfile
+SHA256 b1b19086b98807c67bb66109ddca75ed722c7e7862e0a11239c72a021f95b121 
dist.ini
+SHA256 60f630df121808432e718b2403d3eecc0842b47da8e8a63c9597bea7ab644b06 
doap.xml
+SHA256 241010ec7d91aba873e3305124978b8e71005d4d0fdc7574aad65bfb43a545fd 
example-login/bin/app.psgi
+SHA256 ca7ba902de1a002273d8cda7b57a8232a4184fc67ac84c45403b27f34c4a0f07 
example-login/client/websocket-client-login.pl
+SHA256 3e80536f2d188592d517ceeda8546d6813ef0ba52b01f5c908b94036c876da3a 
example-login/config.yml
+SHA256 15e80fdd0d48363fc7006c10396cbca7804171c25f5191c2de4f8ee0ea754148 
example-login/lib/MyApp.pm
+SHA256 241010ec7d91aba873e3305124978b8e71005d4d0fdc7574aad65bfb43a545fd 
example/bin/app.psgi
+SHA256 ae191b2357f89112b50513d41cc820c54d089716fa75fc4f272356c0848b49fa 
example/config.yml
+SHA256 1fc697dac0bd89bead6675a07b1a55d956856f733656de3ea996d33f16e0736a 
example/lib/MyApp.pm
+SHA256 761c0eb9c04d7de6e2e14faecf053fe9afa6eae9938df70b9fcc006a9920bf15 
lib/Dancer2/Plugin/WebSocket.pm
+SHA256 9a1d79c0d7b95c1552a95c0a8a53ffca9decc0e94fd47355fe956898d5d24cc4 
lib/Dancer2/Plugin/WebSocket/Connection.pm
+SHA256 c8041df607103b814bcea482846de959fdf88cf6b8aab00024aab55f089d81b3 
lib/Dancer2/Plugin/WebSocket/Group.pm
+SHA256 81b8f349f0de6b73d61335880fb6ffdae1bac3891255735e2e2fa3bc8dbf97a5 
t/00-compile.t
+SHA256 3082c4c406a47470a32e036bec446024580befe06cb9d0d3c1b749a7288b4326 
t/00-report-prereqs.dd
+SHA256 32862ed3cdb28367324e2dd1f20af158acc637de8e0487bb296157634e12e08c 
t/00-report-prereqs.t
+SHA256 2112bcec82edd71cede6908d8a9391fafb962b50b25a6bd3d5d9783a5cd64bbb 
t/example.t
+SHA256 63d9827f7014ae7145a2f3dde173b115b0f529a713aad5f747933bd381a6bd05 
xt/release/unused-vars.t
 -----BEGIN PGP SIGNATURE-----
 
-iEYEARECAAYFAl0uT5wACgkQ34Hwf+GwC4zocQCgjpJMWoilvd1kl2PiXvwOOSVI
-S9wAn2z7b3zNvq//WGkjr/wtAfxVFBLT
-=5a+i
+iF0EARECAB0WIQS4RMr2LZlyA/IlbHHfgfB/4bALjAUCYLPCowAKCRDfgfB/4bAL
+jMAJAJ9J1K+3J3KLSbDuaq4p7+EHhT7j2wCgnzwg2xrj6uvaQDSSAOGL2pwkdsI=
+=EWdT
 -----END PGP SIGNATURE-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/cpanfile 
new/Dancer2-Plugin-WebSocket-0.3.1/cpanfile
--- old/Dancer2-Plugin-WebSocket-0.2.0/cpanfile 2019-07-17 00:28:44.000000000 
+0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/cpanfile 2021-05-30 18:51:47.000000000 
+0200
@@ -1,3 +1,6 @@
+# This file is generated by Dist::Zilla::Plugin::CPANFile v6.017
+# Do not edit this file directly. To change prereqs, edit the `dist.ini` file.
+
 requires "Dancer2::Plugin" => "0";
 requires "JSON::MaybeXS" => "0";
 requires "Moo" => "0";
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/doap.xml 
new/Dancer2-Plugin-WebSocket-0.3.1/doap.xml
--- old/Dancer2-Plugin-WebSocket-0.2.0/doap.xml 2019-07-17 00:28:44.000000000 
+0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/doap.xml 2021-05-30 18:51:47.000000000 
+0200
@@ -28,6 +28,12 @@
   </helper>
   <helper>
     <foaf:Person>
+      <foaf:name>Vladislav Kantor</foaf:name>
+      <foaf:mbox rdf:resource="mailto:[email protected]"; />
+    </foaf:Person>
+  </helper>
+  <helper>
+    <foaf:Person>
       <foaf:name>Yanick Champoux</foaf:name>
       <foaf:mbox rdf:resource="mailto:[email protected]"; />
     </foaf:Person>
@@ -71,5 +77,17 @@
       <dc:issued 
rdf:datatype="http://www.w3.org/2001/XMLSchema#date";>2019-01-27</dc:issued>
     </Version>
   </release>
+  <release>
+    <Version>
+      <revision 
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>0.2.0</revision>
+      <dc:issued 
rdf:datatype="http://www.w3.org/2001/XMLSchema#date";>2019-07-16</dc:issued>
+    </Version>
+  </release>
+  <release>
+    <Version>
+      <revision 
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";>0.3.0</revision>
+      <dc:issued 
rdf:datatype="http://www.w3.org/2001/XMLSchema#date";>2021-05-30</dc:issued>
+    </Version>
+  </release>
   <programming-language>Perl</programming-language>
 </Project>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/example-login/bin/app.psgi 
new/Dancer2-Plugin-WebSocket-0.3.1/example-login/bin/app.psgi
--- old/Dancer2-Plugin-WebSocket-0.2.0/example-login/bin/app.psgi       
1970-01-01 01:00:00.000000000 +0100
+++ new/Dancer2-Plugin-WebSocket-0.3.1/example-login/bin/app.psgi       
2021-05-30 18:51:47.000000000 +0200
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+use MyApp;
+use Plack::Builder;
+use Plack::App::WebSocket;
+
+builder {
+    mount( MyApp->websocket_mount );
+    mount '/' => MyApp->to_app;
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/example-login/client/websocket-client-login.pl
 
new/Dancer2-Plugin-WebSocket-0.3.1/example-login/client/websocket-client-login.pl
--- 
old/Dancer2-Plugin-WebSocket-0.2.0/example-login/client/websocket-client-login.pl
   1970-01-01 01:00:00.000000000 +0100
+++ 
new/Dancer2-Plugin-WebSocket-0.3.1/example-login/client/websocket-client-login.pl
   2021-05-30 18:51:47.000000000 +0200
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use AnyEvent::WebSocket::Client 0.12;
+use JSON qw( to_json from_json );
+use Data::Dumper;
+
+my $token = 'CqPoYBz1lmhjNHnzM9AzOYH9RvhpG2Xcg1vqfN8yKCY';
+my $url = "ws://localhost:5000/ws/$token";
+
+my $client = AnyEvent::WebSocket::Client->new();
+my $conn = $client->connect($url)->recv;
+
+$conn->send(to_json({hello => 'Dancer'}));
+$conn->on(each_message => sub {
+    my ($conn, $message) = @_;
+    my $msg = from_json($message->body);
+    print Dumper($msg);
+});
+
+AnyEvent->condvar->recv;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/example-login/config.yml 
new/Dancer2-Plugin-WebSocket-0.3.1/example-login/config.yml
--- old/Dancer2-Plugin-WebSocket-0.2.0/example-login/config.yml 1970-01-01 
01:00:00.000000000 +0100
+++ new/Dancer2-Plugin-WebSocket-0.3.1/example-login/config.yml 2021-05-30 
18:51:47.000000000 +0200
@@ -0,0 +1,18 @@
+appname: "foo"
+
+engines:
+    session:
+        Simple:
+            cookie_name: example.session
+
+plugins:
+    WebSocket:
+        serializer: 1
+        login: 1
+    Auth::Extensible:
+        realms:
+            config:
+                provider: Config
+                users:
+                    - user: websocket
+                      pass: secret
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/example-login/lib/MyApp.pm 
new/Dancer2-Plugin-WebSocket-0.3.1/example-login/lib/MyApp.pm
--- old/Dancer2-Plugin-WebSocket-0.2.0/example-login/lib/MyApp.pm       
1970-01-01 01:00:00.000000000 +0100
+++ new/Dancer2-Plugin-WebSocket-0.3.1/example-login/lib/MyApp.pm       
2021-05-30 18:51:47.000000000 +0200
@@ -0,0 +1,145 @@
+package MyApp;
+
+use Dancer2;
+
+use Dancer2::Plugin::WebSocket;
+use Dancer2::Plugin::Auth::Extensible;
+
+=begin comment
+# use this block if you want to check login by IP address and user-agent.
+
+my $login_conn;
+
+hook before => sub {
+    $login_conn->{'ip'} = request->{'env'}->{'REMOTE_ADDR'} eq '127.0.0.1' ? 
request->{'env'}->{'HTTP_X_REAL_IP'} : request->{'env'}->{'REMOTE_ADDR'};
+    $login_conn->{'user-agent'} = request->{'env'}->{'HTTP_USER_AGENT'};
+    $login_conn->{'login'} = logged_in_user ? 1 : 0;
+};
+
+websocket_on_login sub {
+    my( $conn, $env ) = @_;
+
+    my $ip = $env->{'REMOTE_ADDR'} eq '127.0.0.1' ? $env->{'HTTP_X_REAL_IP'} : 
$env->{'REMOTE_ADDR'};
+    if (($login_conn->{'login'}) and ($login_conn->{'ip'} eq $ip) and 
($login_conn->{'user-agent'} eq $env->{'HTTP_USER_AGENT'})) {
+        return 1;
+    } else {
+        warn "require login";
+        return 0;
+    }
+};
+
+#=end comment
+
+=cut
+
+#=begin comment
+# use this block if you want to check login by cookie or by token.
+
+my $login_conn;
+my $cookie_name = 'example.session';
+
+hook before => sub {
+    if (defined cookies->{$cookie_name}) {
+        $login_conn->{'cookie_id'} = cookies->{$cookie_name}->value;
+    }
+    $login_conn->{'login'} = logged_in_user ? 1 : 0;
+};
+
+websocket_on_login sub {
+    my( $conn, $env ) = @_;
+
+    my $token = '/CqPoYBz1lmhjNHnzM9AzOYH9RvhpG2Xcg1vqfN8yKCY';
+    my ($cookie_id) = ($env->{'HTTP_COOKIE'} =~ /$cookie_name=(.*);?/g);
+    if (($token eq $env->{'PATH_INFO'}) or (($login_conn->{'login'}) and 
($login_conn->{'cookie_id'} eq $cookie_id))) {
+        return 1;
+    } else {
+        warn "require login";
+        return 0;
+    }
+};
+
+#=end comment
+
+#=cut
+
+websocket_on_open sub {
+    my( $conn, $env ) = @_;
+    warn "# opening $conn\n";
+};
+
+
+websocket_on_close sub {
+    my( $conn ) = @_;
+    warn "# closing $conn\n";
+};
+
+websocket_on_error sub {
+    my ( $env ) = @_;
+    warn "Something went bonker";
+};
+
+websocket_on_message sub {
+    my( $conn, $message ) = @_;
+
+    if ( $message->{hello} ) {
+        $message->{hello} = 'browser!';
+        $conn->send( $message );
+    }
+
+    if( my $browser = $message->{browser} ) {
+        $conn->add_channels( $browser );
+    }
+
+    if ( my $channel = $message->{emit} ) {
+        $conn->to($channel)->send({ emitting => $channel });
+    }
+
+    if ( my $channel = $message->{broadcast} ) {
+        $conn->to($channel)->broadcast({ broadcasting => $channel });
+    }
+};
+
+get '/' => sub {
+    my $ws_url = websocket_url;
+    my $is_logged = $login_conn->{'login'};
+    return <<"END";
+<html>
+       <head>
+               <script>
+                       var urlMySocket = "$ws_url";
+
+            var mySocket = new WebSocket(urlMySocket);
+            mySocket.sendJSON = function(message) { return 
this.send(JSON.stringify(message)) };
+
+            mySocket.onmessage = function (evt) {
+                console.log( "Got message ", evt.data );
+//                mySocket.close();
+            };
+
+            mySocket.onopen = function(evt) {
+                if ("$is_logged" == true) {
+                    console.log("opening");
+                    let isChrome = /Chrome/.test(navigator.userAgent) && 
/Google Inc/.test(navigator.vendor);
+                    mySocket.sendJSON({
+                        browser: isChrome ? 'chrome' : 'firefox'
+                    })
+                    setTimeout( function() { mySocket.sendJSON({"hello": 
"Dancer"}); }, 2000 );
+                } else {
+                    console.log( "require login");
+                }
+            };
+
+                       </script>
+               </head>
+       <body>
+        <h1>WebSocket client</h1>
+    </body>
+</html>
+END
+};
+
+get '/say_hi' => require_login sub {
+    $_->send([ "Hello!" ]) for websocket_connections;
+};
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/lib/Dancer2/Plugin/WebSocket/Connection.pm 
new/Dancer2-Plugin-WebSocket-0.3.1/lib/Dancer2/Plugin/WebSocket/Connection.pm
--- 
old/Dancer2-Plugin-WebSocket-0.2.0/lib/Dancer2/Plugin/WebSocket/Connection.pm   
    2019-07-17 00:28:44.000000000 +0200
+++ 
new/Dancer2-Plugin-WebSocket-0.3.1/lib/Dancer2/Plugin/WebSocket/Connection.pm   
    2021-05-30 18:51:47.000000000 +0200
@@ -1,7 +1,7 @@
 package Dancer2::Plugin::WebSocket::Connection;
 our $AUTHORITY = 'cpan:YANICK';
 # ABSTRACT: Role tying Plack::App::WebSocket::Connection with the Dancer 
serializer
-$Dancer2::Plugin::WebSocket::Connection::VERSION = '0.2.0';
+$Dancer2::Plugin::WebSocket::Connection::VERSION = '0.3.1';
 
 
 use Scalar::Util qw/ refaddr /;
@@ -89,7 +89,7 @@
 
 =head1 VERSION
 
-version 0.2.0
+version 0.3.1
 
 =head1 DESCRIPTION
 
@@ -98,19 +98,21 @@
 
 =head2 Attributes
 
-=over serializer
+=over 4
+
+=item serializer
 
 Serializer object used to serialize/deserialize messages. If it's not
-C<undef>, all messages that are not L<AnyEvent::WebSocket::Message> objects 
+C<undef>, all messages that are not L<AnyEvent::WebSocket::Message> objects
 are assumed to be JSON and will be deserialized
 before being passed to the handlers, and will be serialized after being
-give to C<send>. 
+give to C<send>.
 
-=over id
+=item id
 
-A numerical value that is the id of the connection. 
+A numerical value that is the id of the connection.
 
-=item
+=back
 
 =head2 Methods
 
@@ -128,7 +130,7 @@
 
 =item in_channel( @channels )
 
-Returns C<true> if the connection belongs to at least one of the 
+Returns C<true> if the connection belongs to at least one of the
 given C<@channels>.
 
 =item to( @channels )
@@ -138,13 +140,15 @@
 
     $conn->to( 'players' )->send( "game about to begin" );
 
+=back
+
 =head1 AUTHOR
 
 Yanick Champoux <[email protected]>
 
 =head1 COPYRIGHT AND LICENSE
 
-This software is copyright (c) 2019, 2017 by Yanick Champoux.
+This software is copyright (c) 2021, 2019, 2017 by Yanick Champoux.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/lib/Dancer2/Plugin/WebSocket/Group.pm 
new/Dancer2-Plugin-WebSocket-0.3.1/lib/Dancer2/Plugin/WebSocket/Group.pm
--- old/Dancer2-Plugin-WebSocket-0.2.0/lib/Dancer2/Plugin/WebSocket/Group.pm    
2019-07-17 00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/lib/Dancer2/Plugin/WebSocket/Group.pm    
2021-05-30 18:51:47.000000000 +0200
@@ -1,7 +1,7 @@
 package Dancer2::Plugin::WebSocket::Group;
 our $AUTHORITY = 'cpan:YANICK';
 # ABSTACT: Grouping of connections to send messages to
-$Dancer2::Plugin::WebSocket::Group::VERSION = '0.2.0';
+$Dancer2::Plugin::WebSocket::Group::VERSION = '0.3.1';
 
 use strict;
 use warnings;
@@ -26,7 +26,7 @@
 
     my $channels = Set::Tiny->new( @{$self->channels} );
 
-    return grep { 
+    return grep {
         $_->in_channel($channels) and
         ( !$omit_self or $self->source->id != $_->id )
     } values %{ $self->source->manager->connections };
@@ -46,6 +46,7 @@
     $_->send(@args) for $self->targets(1);
 }
 
+
 1;
 
 __END__
@@ -60,7 +61,7 @@
 
 =head1 VERSION
 
-version 0.2.0
+version 0.3.1
 
 =head1 SYNOPSIS
 
@@ -103,13 +104,15 @@
         }
     }
 
+=back
+
 =head1 AUTHOR
 
 Yanick Champoux <[email protected]>
 
 =head1 COPYRIGHT AND LICENSE
 
-This software is copyright (c) 2019, 2017 by Yanick Champoux.
+This software is copyright (c) 2021, 2019, 2017 by Yanick Champoux.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/lib/Dancer2/Plugin/WebSocket.pm 
new/Dancer2-Plugin-WebSocket-0.3.1/lib/Dancer2/Plugin/WebSocket.pm
--- old/Dancer2-Plugin-WebSocket-0.2.0/lib/Dancer2/Plugin/WebSocket.pm  
2019-07-17 00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/lib/Dancer2/Plugin/WebSocket.pm  
2021-05-30 18:51:47.000000000 +0200
@@ -1,7 +1,7 @@
 package Dancer2::Plugin::WebSocket;
 our $AUTHORITY = 'cpan:YANICK';
 # ABSTRACT: add a websocket interface to your Dancers app
-$Dancer2::Plugin::WebSocket::VERSION = '0.2.0';
+$Dancer2::Plugin::WebSocket::VERSION = '0.3.1';
 
 use v5.12.0;
 
@@ -19,6 +19,11 @@
     },
 );
 
+has login => (
+    is => 'ro',
+    from_config => sub { 0 },
+);
+
 has mount_path => (
     is => 'ro',
     from_config => sub { '/ws' },
@@ -47,6 +52,12 @@
     },
 );
 
+has 'on_login' => (
+    is => 'rw',
+    plugin_keyword => 'websocket_on_login',
+    default => sub { sub { } },
+);
+
 has connections => (
     is => 'ro',
     default => sub{ {} },
@@ -79,6 +90,12 @@
             my $conn = shift; ## Plack::App::WebSocket::Connection object
             my $env = shift;  ## PSGI env
 
+            if ($self->login) {
+                if (!$self->on_login->($conn, $env)) {
+                    return;
+                }
+            }
+
             require Moo::Role;
 
             Moo::Role->apply_roles_to_object(
@@ -131,7 +148,7 @@
 
 =head1 VERSION
 
-version 0.2.0
+version 0.3.1
 
 =head1 SYNOPSIS
 
@@ -160,6 +177,7 @@
         WebSocket:
             # default values
             serializer: 0
+            login: 0
             mount_path: /ws
 
 F<MyApp.pm>:
@@ -266,6 +284,40 @@
 object and the Plack
 C<$env> hash as arguments.
 
+=head2 websocket_on_login sub { ... }
+
+    websocket_on_login sub {
+        my( $conn, $env ) = @_;
+        ...;
+    };
+
+Code invoked when a new socket is opened. Gets the
+connection object and the Plack C<$env> hash as arguments.
+
+Example: return true if user is logged in and the webapp http_cookie is the 
same as the websocket.
+
+    my $login_conn;
+    my $cookie_name = 'example.session';
+
+    hook before => sub {
+        if (defined cookies->{$cookie_name}) {
+            $login_conn->{'cookie_id'} = cookies->{$cookie_name}->value;
+        }
+        $login_conn->{'login'} = logged_in_user ? 1 : 0;
+    };
+
+    websocket_on_login sub {
+        my( $conn, $env ) = @_;
+
+        my ($cookie_id) = ($env->{'HTTP_COOKIE'} =~ /$cookie_name=(.*);?/g);
+        if (($login_conn->{'login'}) and ($login_conn->{'cookie_id'} eq 
$cookie_id)) {
+            return 1;
+        } else {
+            warn "require login";
+            return 0;
+        }
+    };
+
 =head2 websocket_on_close sub { ... }
 
     websocket_on_close sub {
@@ -365,7 +417,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-This software is copyright (c) 2019, 2017 by Yanick Champoux.
+This software is copyright (c) 2021, 2019, 2017 by Yanick Champoux.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Dancer2-Plugin-WebSocket-0.2.0/t/00-compile.t 
new/Dancer2-Plugin-WebSocket-0.3.1/t/00-compile.t
--- old/Dancer2-Plugin-WebSocket-0.2.0/t/00-compile.t   2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/t/00-compile.t   2021-05-30 
18:51:47.000000000 +0200
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.052
+# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058
 
 use Test::More;
 
@@ -18,7 +18,9 @@
 
 # no fake home requested
 
-my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib';
+my @switches = (
+    -d 'blib' ? '-Mblib' : '-Ilib',
+);
 
 use File::Spec;
 use IPC::Open3;
@@ -32,12 +34,19 @@
     # see L<perlfaq8/How can I capture STDERR from an external command?>
     my $stderr = IO::Handle->new;
 
-    my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', 
"require q[$lib]");
+    diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . 
$str . q{'} }
+            $^X, @switches, '-e', "require q[$lib]"))
+        if $ENV{PERL_COMPILE_TEST_DEBUG};
+
+    my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', 
"require q[$lib]");
     binmode $stderr, ':crlf' if $^O eq 'MSWin32';
     my @_warnings = <$stderr>;
     waitpid($pid, 0);
     is($?, 0, "$lib loaded ok");
 
+    shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
+        and not eval { +require blib; blib->VERSION('1.01') };
+
     if (@_warnings)
     {
         warn @_warnings;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Dancer2-Plugin-WebSocket-0.2.0/t/00-report-prereqs.dd 
new/Dancer2-Plugin-WebSocket-0.3.1/t/00-report-prereqs.dd
--- old/Dancer2-Plugin-WebSocket-0.2.0/t/00-report-prereqs.dd   2019-07-17 
00:28:44.000000000 +0200
+++ new/Dancer2-Plugin-WebSocket-0.3.1/t/00-report-prereqs.dd   2021-05-30 
18:51:47.000000000 +0200
@@ -27,12 +27,12 @@
                     },
        'test' => {
                    'recommends' => {
-                                   'CPAN::Meta' => '2.120900',
-                                   'EV' => '0',
-                                   'Mojolicious' => '0',
-                                   'Plack::Util' => '0',
-                                   'Twiggy::Server' => '0'
-                                 },
+                                     'CPAN::Meta' => '2.120900',
+                                     'EV' => '0',
+                                     'Mojolicious' => '0',
+                                     'Plack::Util' => '0',
+                                     'Twiggy::Server' => '0'
+                                   },
                    'requires' => {
                                    'ExtUtils::MakeMaker' => '0',
                                    'File::Spec' => '0',

++++++ cpanspec.yml ++++++
---
#description_paragraphs: 3
#description: |-
#  override description from CPAN
#summary: override summary from CPAN
#no_testing: broken upstream
#sources:
#  - source1
#  - source2
#patches:
#  foo.patch: -p1
#  bar.patch:
#  baz.patch: PATCH-FIX-OPENSUSE
#preamble: |-
# BuildRequires:  gcc-c++
#post_prep: |-
# hunspell=`pkg-config --libs hunspell | sed -e 's,-l,,; s,  *,,g'`
# sed -i -e "s,hunspell-X,$hunspell," t/00-prereq.t Makefile.PL 
#post_build: |-
# rm unused.files
#post_install: |-
# sed on %{name}.files
#license: SUSE-NonFree
#skip_noarch: 1
#custom_build: |-
#./Build build flags=%{?_smp_mflags} --myflag
#custom_test: |-
#startserver && make test
#ignore_requires: Bizarre::Module
#skip_doc: regexp_to_skip_for_doc.*
#add_doc: files to add to docs
#misc: |-
#anything else to be added to spec file
#follows directly after %files section, so it can contain new blocks or also
#changes to %files section

Reply via email to