⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcbconference.java

📁 著名的dialogic电话语音卡的java驱动程序,已经验证可用。
💻 JAVA
字号:
// DCBConference: Manage DCB conferences
// $Id: DCBConference.java,v 1.2 2003/07/24 20:26:46 cgm8 Exp $
/* 
 * Copyright (c) 1999 Carlos G Mendioroz.
 *
 *  This file is part of D4J.
 *
 *  D4J is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *  
 *  D4J is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *  
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *  Boston, MA  02111-1307, USA.
 *
 * Report problems and direct all questions to:
 *
 *	tron@acm.org
 */
package local.dialogic;

public class DCBConference extends Conference
{

    // Class variables
    private static Conference server;
    
    static {
        server = null;
    }
    
    /** Open a dcb device */
    public static void init(String name)
    {
        // dcbBnDm
        if (! name.substring(0, 4).equals("dcbB"))
            throw new RuntimeException("DCBConference.init: bad name");
        int device = Dialogic.dcb_open(name, 0);

        int di = name.indexOf('D');
        if (di < 0) {
            // opening a board, should be another class ?
            synchronized(boards) {
                boards.put(name, new Integer(device));
            }
        } else {
            String boardname = name.substring(0, di);
            synchronized(boards) {
                if (boards.get(boardname) == null) {
                    init(boardname);
                }
            }

            dsps.setSize(openDsps+1);
            dsps.setElementAt(new Integer(device), openDsps++);
            // Init server object
            if (server == null)
                server = new DCBConference(-1, -1);
            Channel.register(server, device);
        }
    }

    public DCBConference() {
        this(NOBEEP, NODIGITS);
    }

    public DCBConference(int attributes, int digitMask) {
        super(attributes,digitMask);
    }
    
    synchronized void _add(CDT cdt) {
        int attributes = cdt.chan_attr;
        if (conf < 0) {
            CDT cdts[] = new CDT[1];
            cdts[0] = cdt;
            // Create
            conf = Dialogic.dcb_estconf(dsp, cdts, attr);
            cdt.chan_lts = cdt.chan_attr;
            cdt.chan_attr = attributes;
            Dialogic.dcb_setdigitmsk(dsp, conf, digits);
            if ((Dialogic.debug & Dialogic.DEBUG_CONFERENCE) != 0)
                System.out.println("New DCBconference " + this.toString());
            
       } else {
            // Add
            Dialogic.dcb_addtoconf(dsp, conf, cdt);
            cdt.chan_lts = cdt.chan_attr;
            cdt.chan_attr = attributes;
        }
    }
    
    public void finalize() throws Throwable 
    {
        close();
        super.finalize();
    }
    
    public synchronized void close()
    {
        if (conf < 0)
            return;
        Dialogic.dcb_delconf(dsp, conf);
        if ((Dialogic.debug & Dialogic.DEBUG_CONFERENCE) != 0)
            System.out.println("Closed DCBconference " + this.toString());
        super.close();
        conf = -1;
    }
    
    public boolean service(EVT evt) {
        if (evt.type == EVT.DCBEV_DIGIT) {  
            CDT cdt = CDT.atTs(evt.line);
            if (cdt != null) {
                cdt.channel.newEvent(evt);
                return true;
            }
        }
        return false;
    }
    
    synchronized void _free(CDT cdt) {
        if(members.size() == 1) {
            // Tier down
            Dialogic.dcb_delconf(dsp, conf);
            if ((Dialogic.debug & Dialogic.DEBUG_CONFERENCE) != 0)
                System.out.println("Freed DCBconference " + this.toString());
            conf = -1;
        } else {
            Dialogic.dcb_remfromconf(dsp, conf, cdt);
        }
    }
    
    public String toString() {
        StringBuffer desc = new StringBuffer();
        if (conf < 0) {
            if (attr == -1)
                return "DCB service";
            desc.append("Unestablished DCBConference");
        } else
            desc.append("DCBConference " + conf);
        desc.append(" with "+ members.size() + " (" + attr + ")");
        return desc.toString();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -