# My first Module

**URL:** <https://community.wowza.com/t/my-first-module/35169>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [July 27, 2010, 4:35pm UTC](https://community.wowza.com/t/my-first-module/35169 "2010-07-27T16:35:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![capos\_capos](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@capos\_capos](https://community.wowza.com/u/capos_capos)\
**Post date:** [July 27, 2010, 4:35pm UTC](https://community.wowza.com/t/my-first-module/35169/1 "2010-07-27T16:35:22Z")

</div>

TOPIC EDITED:

Hello this is my first post, and my first module.

included banned ips, limit viewers channel and server, auto play on slot free, channels vips

sorry for my bad english

[PHP]

package capos;

import com.wowza.wms.client.\*;

import com.wowza.wms.request.\*;

import java.util.\*;

import com.wowza.wms.application.\*;

import com.wowza.wms.amf.\*;

import com.wowza.wms.module.\*;

import com.wowza.wms.stream.\*;

public class Capos extends ModuleBase

{

private int MaxViewersPerChannel = 200;

private int MaxViewersTotal = 2000;

String vips[] = {“live1”,“live2”};

String ipsbanned[] = {“127.0.0.1”,“ipbaned2”,“etc…”};

public void play(IClient client, RequestFunction function, AMFDataList params)

{

IMediaStream stream = getStream(client, function);

if (stream == null)

{

sendStreamOnStatusError(stream, “NetStream.Play.Failed”, “Null stream”);

return;

}

for (int i=0;i\<ipsbanned.length; i++)

{

if (client.getIp().equals(ipsbanned\*))\*

_{_

_sendStreamOnStatusError(stream, “NetStream.Play.Failed”, “IP banned”);_

_return;_

_}_

_}_

_if(getParamType(params, PARAM1) == AMFData.DATA\_TYPE\_STRING)_

_{_

_String streamName = getParamString(params, PARAM1);_

_if(isvip(streamName))_

_{_

_this.invokePrevious(client, function, params);_

_return;_

_}_

_IApplicationInstance appInstance = client.getAppInstance();_

_List streamList = appInstance.getPlayStreamsByName(streamName);_

_boolean waiting = false;_

_int viewers= 0;_

_if(streamList!=null)_

_{_

_viewers = streamList.size();_

_if (viewers \> MaxViewersPerChannel)_

_{_

_sendResult(client, params, “Max Channel viewers, waiting for slot…”);_

_waiting = true;_

_}_

_}_

_viewers = 0;_

_if(waiting)_

_{_

_while(true)_

_{_

_try {_

_Thread.sleep(5000);_

_} catch (InterruptedException e) {_

_// TODO Auto-generated catch block_

_e.printStackTrace();_

_}_

_streamList = appInstance.getPlayStreamsByName(streamName);_

_if (streamList != null)_

_{_

_viewers = streamList.size();_

_if (viewers \> MaxViewersPerChannel)_

_{_

_sendResult(client, params, “Max Channel viewers, waiting for slot…”);_

_}_

_else_

_{_

_waiting = false;_

_break;_

_}_

_}_

_}_

_}_

_MediaStreamMap streams = appInstance.getStreams();_

_List streamNames = streams.getPublishStreamNames();_

_Iterator iter = streamNames.iterator();_

_viewers = 0;_

_while(iter.hasNext())_

_{_

_String Name = iter.next();_

_streamList = appInstance.getPlayStreamsByName(Name);_

_if (streamList == null)_

_continue;_

_viewers += streamList.size();_

_if(viewers \> MaxViewersTotal)_

_{_

_sendResult(client, params, “Max Total viewers, waiting for slot…”);_

_waiting = true;_

_break;_

_}_

_}_

_if(waiting)_

_{_

_while(true)_

_{_

_try {_

_Thread.sleep(5000);_

_} catch (InterruptedException e) {_

_// TODO Auto-generated catch block_

_e.printStackTrace();_

_}_

_viewers = 0;_

_waiting = false;_

_streams = appInstance.getStreams();_

_streamNames = streams.getPublishStreamNames();_

_iter = streamNames.iterator();_

_while(iter.hasNext())_

_{_

_String Name = iter.next();_

_streamList = appInstance.getPlayStreamsByName(Name);_

_if (streamList == null)_

_continue;_

_viewers += streamList.size();_

_if(viewers \> MaxViewersTotal)_

_{_

_break;_

_}_

_}_

_if(viewers \> MaxViewersTotal)_

_{_

_sendResult(client, params, “Max Total viewers, waiting for slot…”);_

_}_

_else_

_{_

_break;_

_}_

_}_

_}_

_this.invokePrevious(client, function, params);_

_}_

_}_

_public boolean isvip(String Name)_

_{_

_for (int i=0;i\<vips.length; i++)_

_{_

_if (Name.equals(vips\*))\*_

_{_

_return true;_

_}_

_}_

_return false;_

_}_

_}_

_[/PHP]_

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [July 27, 2010, 10:39pm UTC](https://community.wowza.com/t/my-first-module/35169/2 "2010-07-27T22:39:11Z")

</div>

Use:

```auto
Thread.sleep(5000);

```

Richard

---

<div class="post-metadata">

**Author:** ![capos\_capos](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@capos\_capos](https://community.wowza.com/u/capos_capos)\
**Post date:** [July 27, 2010, 4:45pm UTC](https://community.wowza.com/t/my-first-module/35169/3 "2010-07-27T16:45:41Z")

</div>

> Use:
> 
> ```auto
> Thread.sleep(5000);
> 
> ```
> 
> Richard

thanks solved

---

<div class="post-metadata">

**Author:** ![capos\_capos](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@capos\_capos](https://community.wowza.com/u/capos_capos)\
**Post date:** [July 27, 2010, 5:01pm UTC](https://community.wowza.com/t/my-first-module/35169/4 "2010-07-27T17:01:34Z")

</div>

post edited for users use module.
